2015-10-21 86 views
0

以下是索引操作的一段代碼。有人可以解釋我使用第三個參數:class =>'action show',在行號27,28和29的link_to助手中。如果沒有這個,代碼似乎也能正常工作。我是一名鐵桿菜鳥,並提前致謝。link_to方法中的額外參數

<div class="subjects index"> 
    <h2>Subjects</h2> 

    <%= link_to("Add New Subject", '#', :class => 'action new') %> 

    <table class="listing" summary="Subject list"> 
    <tr class="header"> 
     <th>&nbsp;</th> 
     <th>Subject</th> 
     <th>Visible</th> 
     <th>Pages</th> 
     <th>Actions</th> 
    </tr> 
    <% @subjects.each do |subject| %> 
    <tr> 
     <td><%= subject.position %></td> 
     <td><%= subject.name %></td> 
     <td class="center"><%= subject.visible ? 'Yes' : 'No' %></td> 
     <td class="center"> 
     <%if(subject.pages!=nil)%> 
     <%= subject.pages.size %> 
     <% else %> 
     <%= "1" %> 
     <% end %> 
     </td> 
     <td class="actions"> 
     <%= link_to("Show", {:action => "show",:id => subject.id}, :class => 'action show') %> 
     <%= link_to("Edit", '#', :class => 'action edit') %> 
     <%= link_to("Delete", '#', :class => 'action delete') %> 
     </td> 
    </tr> 
    <% end %> 
    </table> 
</div> 

回答