Ruby on rails 3 link_to controller and action

后端 未结 3 424
长情又很酷
长情又很酷 2020-12-30 19:24

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

相关标签:
3条回答
  • 2020-12-30 19:44
    link_to "Label", :controller => :my_controller, :action => :index
    

    See url_for.

    0 讨论(0)
  • 2020-12-30 19:58

    Also with CSS:

    <%= link_to "Purchase", { :controller => :transactions, :action => :purchase }, { class: "btn btn-primary btn-lg", style: "width: 100%;" } %>
    
    0 讨论(0)
  • 2020-12-30 20:02

    If you want to pass params too then do

    <%= link_to student.name,  controller: "users", action: "show", id: student.id, partial: "profile"  %> 
    
    0 讨论(0)
提交回复
热议问题