how to iterate inside a simple_fields_for?
ruby, ruby-on-rails-3, simple-form
Solution
Like mentioned it is possible in Rails 4 after the merge https://github.com/rails/rails/pull/5746. In Rails 4 you can use `.index` on the 'builder':
<%= f.simple_fields_for :schedules do |builder| %>
<%= builder.input :day, value: builder.index+1 %>
<% end %>
Problem
I need to iterate inside the simple_fields_for block to assign a number [0 to 6] to the :day field. Controller ``` 7.times { @doctor.schedules.build } ``` View ``` <tr> <% @i = 0 %> <%= f.simple_fields_for :schedules do |builder| %> <td> <%= builder.input :day, value: @y, wrapper: :check %> <%= builder.input :is_available, as: :boolean, label: false, wrapper: :check %> <% @i += 1 %> </td> <% end %> </tr> ``` obviously this will start from 1 until 7, how can I make it iterate from 0 to 6?