Forum: Ruby on Rails Storing user setting

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.
90c96b330a1e4ec7555b879b864d571c?d=identicon&s=25 Andy (Guest)
on 2006-05-01 19:21
Hi,

Where should i store user settings? Well, I have a class called Book and
one of the fields is called status. When a new Book is created, the
status field is assigned a value according to what the user set in the
setting.
So, I will have a form for the user to change the settings of the app
including the initial status of the Book model.
I'm thinking of using a table to store the settings, but i think it's a
bit too much.

Thanks,

Andy.
47d0bfbb5b81fa04559b0b7790d17106?d=identicon&s=25 Bill Roberts (bill)
on 2006-05-01 19:51
Andy wrote:
> Hi,
>
> Where should i store user settings? Well, I have a class called Book and
> one of the fields is called status. When a new Book is created, the
> status field is assigned a value according to what the user set in the
> setting.
> So, I will have a form for the user to change the settings of the app
> including the initial status of the Book model.
> I'm thinking of using a table to store the settings, but i think it's a
> bit too much.
>
> Thanks,
>
> Andy.

Andy - my opinion would be to use a database table. Why would this be
too much?  The user settings sounds like something that needs to be
persisted, and the db is the ideal place for storing persistent data,
maybe even the only sensible place. Also, Rails makes it easy to get
stuff in and out of the db so it isn't much programming effort.
90c96b330a1e4ec7555b879b864d571c?d=identicon&s=25 Andy (Guest)
on 2006-05-01 20:18
> Andy - my opinion would be to use a database table. Why would this be
> too much?  The user settings sounds like something that needs to be
> persisted, and the db is the ideal place for storing persistent data,
> maybe even the only sensible place. Also, Rails makes it easy to get
> stuff in and out of the db so it isn't much programming effort.

Well, it's because there are only a few things that the user could
change, so i thought database is a bit too much.
If i use a database, what would be the best approach to store different
settings? Do i use store a single value in each row e.g. a row to store
the status value, another row to store the default admin's email, etc?
Or do i store them as a single row under different fields?

One more thing, I'm using the example from the Agile Web Development in
Rails to handle uncaught exception. In my application controller i
declared a method called
'rescue_action_in_public(exception)'
The thing is, the exception doesn't get caught. The exception gets
caught if i change the method to
'rescue_action'
Any idea why?

Thanks,

Andy.
B62e6ee89ae6b7192f577991a85eff13?d=identicon&s=25 Wes Hatchett (Guest)
on 2006-05-01 20:49
> Well, it's because there are only a few things that the user could
> change, so i thought database is a bit too much.
> If i use a database, what would be the best approach to store different
> settings? Do i use store a single value in each row e.g. a row to store
> the status value, another row to store the default admin's email, etc?
> Or do i store them as a single row under different fields?
>

From the sounds of it, you aren't using a db with your app already? From
that standpoint I understand why the db seems like a hassle, but it kind
of negates the reasons for using a framework like rails to start with.

At any rate, it's not too little information for the database. You would
probably want to have a ROW for each user, and COLUMNS containing their
settings, as you described last. That way you can make a query for one
unique field (username/id, whatever) and get all of the settigs.
6661ef9d747db3af8896cd94959d717d?d=identicon&s=25 Paul Barry (Guest)
on 2006-05-03 18:58
(Received via mailing list)
It sounds like you are not trying to store a user setting, but a setting
(or
to be more technically correct, a property or attribute) of the Book.
The
Book should have a status property/attribute and therefore the
corresponding
books table in the database should have a column called status.
This topic is locked and can not be replied to.