Implementing global app settings
I am wondering what the best way to go about setting up Settings for an application. Settings will consist of name, address, phone number, and some other project specific entries. What has me a little confused is that while many users will be accessing the app, these settings are to be specific to the app and not the user.
I will be letting admins edit these settings and my thought was to setup a model for Settings to store the values in the DB. However there wont be multiple Settings entires in the DB I just need one.
Is a model the right way to go in this instance and maybe I just manually create one entry for Settings that can be edited by anyone with the correct role?
Seems like a simple concept to me, but getting a little mixed up by it.
I would do exactly that RJ
In many of my apps I have a global scope for my settings table that just returns the last row for the settings table. Since there's only one, it returns the only one. In my controllers I just edit that global one and it's worked fine for me.
Sidenote: There's no wrong answer here
Hi RJ,
If you want a gem solution, you can look at the rails-settings gem: https://github.com/ledermann/rails-settings
I haven't used it personally so I can't give much details, but it does look like they have a decent syntax. I generally just do as you and Andrew suggested, a single table with one row for app wide settings.
Thanks Andrew. Wanted to make sure my head was in the right place and I wan't missing something obvious.