开发者

Ruby on rails 3 link_to controller and action

开发者 https://www.devze.com 2023-02-23 13:46 出处:网络
I know this is probably a pretty simple concept. I am trying to create a link to a controller and actio开发者_JS百科n. For example I have a link in my layout file to update a record when a link is cli

I know this is probably a pretty simple concept. I am trying to create a link to a controller and actio开发者_JS百科n. 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?


link_to "Label", :controller => :my_controller, :action => :index

See url_for.


Also with CSS:

<%= link_to "Purchase", { :controller => :transactions, :action => :purchase }, { class: "btn btn-primary btn-lg", style: "width: 100%;" } %>


If you want to pass params too then do

<%= link_to student.name,  controller: "users", action: "show", id: student.id, partial: "profile"  %> 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号