Where would you store a users preferences in a Rails app?
Should I put it in the User Model or just use serialize
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is really dependent of your app. How big is it, will it grow in the future, how many settings are there, will the number of settings increase, etc.
If you have only a few settings (my personal limit is 5) you can probably save them in your
Usermodel. Pros: Easy to implement. Cons: New settings need changes in the database, i.e. migrations every time you add a new one or change an existing one.If you have more settings, and they going to change or increase in number, you probably have an easier time saving them in their own model. The best way is to use some kind of existing Key-Value storage, or faking your own. Pro: You can easily add new settings, or change existent. Cons: Harder to implement, can be overkill for a small app.