Reputation: 15
Probably a basic question, but new to Rails and web programming and haven't found a good answer in researching through this site.
Across four pages and three controllers and one database, starting at the home page(pages controller): pick-up 2 params (in a form_for) that will be used in the fourth page to find in records in a database table, and one variable(set in a hidden field) that will be used to determine which information is displayed in the fourth page. On clicking submit, move to a second and third page(categories controller) to pick-up two more params(one on each page) in link_to’s, before moving to the 4th page (products controller) where the variable from the home page is used to determine which information from the products table is to display.
What is the best way and syntax in the link_to to pick-up these params and variable and move them across the controllers and pages? Where would I define this variable?
Upvotes: 0
Views: 125
Reputation: 32748
You have a couple of different choices of a "storage" area that can be used across requests.
The first two are probably the easiest.
I'd probably lean towards the session since thats what it meant for.
If you store this data in the session than you dont have to bother with making sure this data is kept in URLs (so it rules out having to make link_to helpers), that is, the data is always available in the controllers. Of course, have sane fallback mechanisms if you're expecting session data to be set and for whatever reason it is no longer set.
Upvotes: 1