4

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.

Community
  • 1
  • 1
TemporaryName
  • 487
  • 5
  • 16

2 Answers2

4

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.

kcdragon
  • 1,724
  • 1
  • 14
  • 23
  • 1
    Late comment, but in case someone stumbles upon this: We knew we were going to have many settings, otherwise I would recommend this approach. – TemporaryName Aug 30 '19 at 15:23
2

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.