Ruby on rails 3 link_to controller and action

Jason Yost picture Jason Yost · Apr 9, 2011 · Viewed 56.4k times · Source

I know this is probably a pretty simple concept. I am trying to create a link to a controller and action. For example I have a link in my layout file to update a record when a link is clicked, so I need to be able to link to the controller and action. How would I accomplish this?

Answer

Jakub Hampl picture Jakub Hampl · Apr 9, 2011
link_to "Label", :controller => :my_controller, :action => :index

See url_for.