PDA

View Full Version : Multiple screens mapped to one db. table


kxkannan
July 26th, 2006, 10:56 PM
Hello,

I am new to Ruby and Rails. I am trying to develop a screen that maps to a db table. This table has around 25 columns. Showing all of them on a single page doesn't look very nice.

Question is, if I split the data on different screens how do I map them to the same ActiveRecord model class ?

If the user navigates from one screen to another how can I retain the data on a single object from the first screen on the subsequent screens and finally store it in the database ?

Any help or pointers would be appreciated.

Thanks,
Kannan

motobass
July 26th, 2006, 11:51 PM
A little googling suggested the acts_as_state_machine (http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk/) plugin. However, it seems like the main article about this plugin (http://lunchroom.lunchboxsoftware.com/articles/2006/01/21/acts-as-state-machine) is unavailable at the moment I am writing. I am not sure how they intended that plugin to be used for this purpose.

One way to do this is just to keep handing your form values back to the next page as hidden form fields. You can create a model that is not tied to ActiveRecord to hold the data until you have it all. That also gives you the possibility of keeping that object around in the session until they are done and forego the use of hidden form fields. Sessions can time out. Not sure what the downside is of using hidden form fields.

Hope this helps

kxkannan
July 27th, 2006, 04:13 PM
Hello motobass,

Thanks for your suggestions.

Upon further reading on sessions and Flash, I was thinking about similar ideas to what you are suggesting. I can create a model and keep that in Flash or Session and each screen will retrieve the object from session/Flash, update it with it's data and put it back on the session/Flash. In the last screen of the sequence, I can retrieve the object and store it in the database.

I don't want to use a state machine for this issue as it might be an overkill.

Thanks,
Kannan