I'm getting mass-assignment error.
Can't mass-assign protected attributes: 1, 2, 3, 4, 5, 6, 7
These numbers represent the iteration in this loop:
<% (1..7).each do |i| %> <%= select_tag "hour[#{i}][day]", options_for_select(days_hours) %> <% end %>
This is in my model:
attr_accessible :day, :open_time, :close_time
I'm trying to create an array like this:
"hour"=>{ "1"=>{"day"=>"Sunday","open_time"=>"6","close_time"=>"6"}, "2"=>{"day"=>"Sunday","open_time"=>"6","close_time"=>"6"}, "3"=>{"day"=>"Sunday","open_time"=>"6","close_time"=>"6"} }
And I'm trying to save each iteration in a new row into the database
def create @hour = @hourable.hours.new(params[:hour]) end
How do I fix the iteration mass-assignment? or am I doing this all wrong?
Thanks!