Forum: Ruby on Rails What's the best way to manage settings in a Rails app?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
pergesu (Guest)
on 2005-11-14 08:53
(Received via mailing list)
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.

Thanks,
Pat
pergesu (Guest)
on 2005-11-14 09:20
(Received via mailing list)
http://wiki.rubyonrails.com/rails/pages/HowtoAddYo...
gives a good description of different options.

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?

Thanks,
Pat
bpaland (Guest)
on 2005-11-26 13:24
(Received via mailing list)
Hi,

I have to pick this up:

2005/11/14, Pat M. <removed_email_address@domain.invalid>:
> 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?

TIA,
Beate
francois.beausoleil (Guest)
on 2005-11-26 17:26
(Received via mailing list)
Hi !

2005/11/14, Pat M. <removed_email_address@domain.invalid>:
> 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 topic is locked and can not be replied to.