Reputation: 4937
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?
Upvotes: 39
Views: 60700
Reputation: 5861
For Rails 6:
<%= button_to "SIGN IN", { controller: 'o_auth', action: :login }, { class: "btn btn-primary btn-lg", style: "width: 100%;", method: :get} %>
Upvotes: 0
Reputation: 891
If you want to pass params too then do
<%= link_to student.name, controller: "users", action: "show", id: student.id, partial: "profile" %>
Upvotes: 0
Reputation: 1266
Also with CSS:
<%= link_to "Purchase", { :controller => :transactions, :action => :purchase }, { class: "btn btn-primary btn-lg", style: "width: 100%;" } %>
Upvotes: 11
Reputation: 40533
link_to "Label", :controller => :my_controller, :action => :index
See url_for.
Upvotes: 58