Making a table row into a link in Rails

后端 未结 5 1048
刺人心
刺人心 2020-11-30 02:07

I am trying to make a row in a table link to the edit page. I know the links are being created, because I can print them out. I am close, but am missing something importan

5条回答
  •  有刺的猬
    2020-11-30 02:33

    Simple Solution: add a link into a table cell:

    This doesn't answer your question, but it provides a solution to the problem you are likely really after: just add an edit link into a cell, rather than on the table row because having a link on the table row itself may lead to expected results for users. If they are clicking on it, they might not want to be led to an edit link.

    Like my grandpa used to say: KISS - Keep It Simple Stupid

        <% @scouts.each do |scout| %>
            
             
               <%= link_to edit_scout_path(scout), "Edit Scout" %>       
              <%= scout.name %>
              <%= scout.rank %>
              <%= scout.advancement %>
              <%= scout.age %>
            
    

提交回复
热议问题