如何将rails 2.3.5中的类添加到link_to

时间:2013-05-08 06:59:06

标签: ruby-on-rails ruby

我有以下link_to标签但是我不知道如何向它添加html类属性并向我解释代码edit_course_path(course)..的确如此。我是rails的新手

  <% @courses.each do |course| %>
    <li class="list<%=cycle('odd', 'even')%>">
         <div class="category-edit"><%= link_to "#{t('edit_text')}", edit_course_path(course) if permitted_to? :edit, :courses %></div>
         <div class="category-delete">   <%= link_to(t('delete_text'), course_path(course), :method => 'delete', :confirm => "#{t('delete_confirm_msg')}") if permitted_to? :destroy, :courses %></div>
    </li>
  <% end %>

1 个答案:

答案 0 :(得分:0)

一般如此:

<% for employee in @employees %>
   <%= link_to 'Edit', edit_employee_path(employee) if permitted_to? :update, employee , :class => 'some-class'%>
<% end %>