# Storing user setting

**URL:** <https://www.ruby-forum.com/t/storing-user-setting/59208>\
**Category:** Rails\
**Created:** [May 1, 2006, 7:21pm UTC](https://www.ruby-forum.com/t/storing-user-setting/59208 "2006-05-01T19:21:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@andy](https://www.ruby-forum.com/u/andy)\
**Post date:** [May 1, 2006, 7:21pm UTC](https://www.ruby-forum.com/t/storing-user-setting/59208/1 "2006-05-01T19:21:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@andy](https://www.ruby-forum.com/u/andy)\
**Post date:** [May 1, 2006, 7:51pm UTC](https://www.ruby-forum.com/t/storing-user-setting/59208/2 "2006-05-01T19:51:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@andy](https://www.ruby-forum.com/u/andy)\
**Post date:** [May 1, 2006, 8:18pm UTC](https://www.ruby-forum.com/t/storing-user-setting/59208/3 "2006-05-01T20:18:18Z")

</div>

> 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 D. 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.

---

<div class="post-metadata">

**Author:** ![andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@andy](https://www.ruby-forum.com/u/andy)\
**Post date:** [May 3, 2006, 6:58pm UTC](https://www.ruby-forum.com/t/storing-user-setting/59208/4 "2006-05-03T18:58:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@andy](https://www.ruby-forum.com/u/andy)\
**Post date:** [May 1, 2006, 8:49pm UTC](https://www.ruby-forum.com/t/storing-user-setting/59208/5 "2006-05-01T20:49:37Z")

</div>

> 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.
