in the following code, I want to assign a different label to the text field for each iteration.
<%= f.field_for :skills do |s| %>
<li>
<label>Skills</label>
<%= s.text_field :name %>
</li>
<% end %>
How can I do that?
Here is my controller code, where I create three different skill objects:
def edit
3.times{resource.skills.build}
render_with_scope :edit
end
You could do something like this:
It is preferred to use
s.label :name, since that will make sure when you click the label, the text-box will get the focus. But the value of the label can be overruled, as i did here.I am not quite sure what else you could mean with changing the label for each item, so if you could make that clearer.
Hope this helps.