2013-03-20 3 views
0

Я пытаюсь создать ярлык в своих рельсах. Этикетка должна в конечном счете выглядеть следующим образом:Rails Form Label

<label for="member_ids_index><span></span>collaborator.name</label> 

где индекс является текущей итерации моего цикла ниже, и collaborator.name является строкой. По какой-то причине я не могу заставить свою инструкцию f.label правильно ее генерировать. Кто-нибудь может мне помочь? То, что я до сих пор, ниже.

<% if [email protected]_user.all_collaborators.nil? %> 
    <% @current_user.all_collaborators.each_with_index do |collaborator, index| %> 
    <%= check_box_tag "project_ids[#{index}]", collaborator.id %> 
    <%= f.label :member_ids_, "<span></span>collaborator.name %> 
    <br/> 
    <% end %> 
<% end %> 

ответ

0

Использование label_tag:

<% if [email protected]_user.all_collaborators.nil? %> 
    <% @current_user.all_collaborators.each_with_index do |collaborator, index| %> 
    <%= check_box_tag "project_ids[#{index}]", collaborator.id %> 
    <%= label_tag "member_ids_#{index}" do %> 
     <span></span><%= collaborator.name %> 
    <% end %> 
    <br/> 
    <% end %> 
<% end %> 
+0

Совершенная. Спасибо! –