Ruby on Rails : get route using controller, action & param Ruby on Rails : get route using controller, action & param ruby-on-rails ruby-on-rails

Ruby on Rails : get route using controller, action & param


You should be able to use the following

link_to "Link Content", :controller => "my_controller", :action => "my_action", :project_id => 1

This will produce an <a> with a link to your controller/action.


This is the helper that will generate a path like you want:

edit_controller_path(project_id: 1)

You can use this Helper to generate the full path (including host) of the link:

edit_controller_url(project_id: 1)

Edit :More info available at http://guides.rubyonrails.org/routing.html#path-and-url-helpers