0

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?

1
  • Your description is somewhat hard to follow. Could you describe it at a higher level of abstraction? How does what you're trying to do directly relate to the user? Commented Mar 26, 2012 at 21:43

1 Answer 1

1

You have a couple of different choices of a "storage" area that can be used across requests.

  • cookies
  • session
  • query string

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the response. Sent me back into session and found a solution there. Probably not elegant, but it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.