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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---