Pass a variable via Link To

Can anyone tell me how to pass a value from a link_to in a view to a
controler?

The value is just a piece of text for the time being.

<%= link_to ‘About Us’, :action => ‘about’, :params => ‘string’ %>

???

Hi, John,

try link_to ‘about us’, :action => ‘about’, :my_param => “we’re the
greatest” and have a look at the development.log. you should be able to
pick
up params[:my_param] and it should be able to tell you something about
yourself…

Cheers,
Jan

John,

Any param in the url section (second part) of the link_to call that is
not matched with rails routing is passed as a parameter.

<%= link_to ‘Edit’, { :action => ‘edit’, :my_var => ‘dude’ } %>

now in the controller params[:my_var] = ‘dude’

Hope this helps,
Zack

Thanks Guys

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs