TemporaryName
TemporaryName

Reputation: 505

Best way to store user settings

Yes, I saw this post. It seems old and I wanted to ask again, especially with the recent release of Rails 5.

What is the best way to store user settings in Rails? It seems has_easy is a decent way. Rails-cached-settings also seems like a good way - but I dislike that there are no default values and it is... rather ambiguous.

Both of these options seem good, but how do they impact performance? If I only have three settings, is it better to have them directly on the model? What if I have ten?

Edit: has_easy is 8 years old, probably not the best option by now.

Upvotes: 4

Views: 1446

Answers (2)

Alexander Rühle
Alexander Rühle

Reputation: 233

I prefer https://github.com/ledermann/rails-settings for storing model specific settings with optional default values. This stores the settings in a simple has_many association. The data is stored in a Proc. I assume that a simple join will not have a big impact on performance.

Upvotes: 2

kcdragon
kcdragon

Reputation: 1733

I like starting out simple before making things too complex. If you only have three settings per user, it might not be a bad idea to start with them on the model. When it starts to get too complicated, then make the decision to switch to something more extensible. You will have a lot more information at that point to pick the right way to handle settings.

Upvotes: 4

Related Questions