Passing off values

Hi Josh,

Josh Gilman wrote:

How do you pass of values using link_to? Here is what I am trying:

<%= link_to [...] :article => @article.id %>

And then on the next page I am trying to grab the :article value with:

<%= hidden_field_tag :article, params[:article] %>

Except that params[:article] is empty, telling me it didn't pass it off.

Params are the mechanism for passing values from a rendered page back to the controller. Those values can then be used in the controller to do whatever, including using them in the construction / rendering of another page. To do that, you pass the value to the View in the form of an instance variable. Params: view --> controller. Instance variables: controller --> view. So in your case you'd need to do...

controller code: def action   @article = params[:article] end

hth, Bill