views:

159

answers:

2

Hi,

My DB table has a column that can contain a very big amount of data. I do not want this data to be part of the corresponding rails object (model).

How do I tell in the model that I do not want to store this field in memory ?

Initially this comes from the fact that I have a session bigger than 4k and rails raises a ActionController::Session::CookieStore::CookieOverflow exception.

Thanks for your help, Mickael.

+1  A: 

When loading your model you could explicitly set the columns you want to select and skip large columns:

MyModel.find(id, :select => 'column1, column2, column3')
Darin Dimitrov
+1  A: 

You'd have to specify the columns explicitly via the find-option :select. However, storing models in the session is discouraged. How about storing just the object-id in the session, and holding the Model-Object itself in Rails.cache?

Greets

Seb

flitzwald
To be clearer - storing in the session is dangerous for your data validity - models in the session are not updated when data changes in the database unless you do it manually so you will end up with all kinds of weirdness
srboisvert
If you want a bit more about why it is a bad idea from a security point of view look here: http://www.rorsecurity.info/the-book/
srboisvert