How should we manage settings in an app? Typo, for example, has a
settings table with stuff like title, subtitle, enable comments, etc.
It’s basically a name for the setting and the value. Is this the best
approach for settings that should be configured for the app? The
majority of the time they won’t change (title), but you’d use caching
in some place so you don’t take a performance hit. Anyway I’ve just
been wondering the best way to allow users of an app to manage
particular settings.
I’d like to have a nice interface to modify settings, because the end
users won’t have access to the text files to modify settings
themselves. Seems like using a db is the best approach? I just found
out on IRC that if I use a YAML file I can easily save it by calling
save on the YAML object, and it will automatically rewrite the file.
Why does Typo use a db though, and what’s the best approach for me?
I’d like to have a nice interface to modify settings, because the end
users won’t have access to the text files to modify settings
themselves. Seems like using a db is the best approach? I just found
out on IRC that if I use a YAML file I can easily save it by calling
save on the YAML object, and it will automatically rewrite the file.
Why does Typo use a db though, and what’s the best approach for me?
This is also the question I wonder. Did someone already solve this in
rails?
How should we manage settings in an app? Typo, for example, has a
settings table with stuff like title, subtitle, enable comments, etc.
It’s basically a name for the setting and the value. Is this the best
approach for settings that should be configured for the app? The
majority of the time they won’t change (title), but you’d use caching
in some place so you don’t take a performance hit. Anyway I’ve just
been wondering the best way to allow users of an app to manage
particular settings.
You’ll have to decide for yourself what is the best approach. I have
tried the two following ways:
CREATE TABLE settings (
id
name
group_name
description
type
str_value
int_value
product_id
product_category_id
);
and
CREATE TABLE settings (
id
paypal_business
paypal_ipn_url
);
In the first case, I have a table record per setting. Each record can
be edited on a special screen I made in the application. It is
basically the scaffolded list, but I replaced the value columns with a
conditional partial rendering. Then, I show an HTML control depending
on the type of configuration setting.
In the second case, the application is just starting. I’ll have a
single screen where all configuration will be done. It is not done at
the moment, but I will be mostly be able to regenerate it using the
scaffolded edit screen.
In both cases I was after a single thing: ease of backup. Backing up
the DB, I have EVERYTHING - no other files need to be backed up at the
same time.
As I said at start, you’ll need to decide for yourself which method is
best for you, your team, your application and your users, in reverse
order
Have a nice day !
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.