Long introduction:
Normally all data necessary for my web application are stored in session variables. Only if the user explicitly says that something is to be saved, it is stored into the database. (Like saving a comment or creating an order from a shopping cart)
In my latest Rails application I noticed that I really could use many of Rails' ActiveRecord
helpers like find
for example. Unfortunately some functions like find
need a stored record.
I also have a hierarchical structure of temporary ActiveRecords
, but they don't have IDs and I really could use those IDs to identify individual records between controller actions.
Short question:
How can I write these temporary records into the database and thus gain all of the ActiveRecords
functionality, but make sure those records are cleared as soon as the session becomes invalid?