Ruby on Rails: Mass-Assignment on iteration in loop? -
I'm getting an assignment error on a large scale.
Features: 1, 2, 3, 4, 5, 6, 7 These numbers represent recurrence in this loop:
& lt;% (1 ..7). I & Gt%; & Lt;% = select_tag "Hour [# {i}] [days]", option_key_description (day_hur)% & gt; & Lt;% end% & gt; This is in my model:
attr_accessible: day,: open_time, close_time i like this Trying to create an array:
"hour" => {"1" = & gt; {"day" = & gt; "Sunday", "Open_time" = & gt; 6 "," close_time "=> 6 "}," 2 "=> {" day "=> Sunday "," Open_time "=> 6 "," close_time "=> 6 "}," 3 "=> {" day "=" gtc: "Sunday", "open_time" = & gt; "6", "close_time" =>, "6"}} And I'm trying to save every repetition in the database in a new line
def @hour = @ hourable.hours.new (params [ : Hour]] end How do I fix repeated mass assignments? Or am I doing all this wrong?
Thank you!
From the hash, the Active record assumes that '1', '2' and '3' are the properties of the column names or models and As You have not specified the attr_accessible option column, it is throwing -andendement error otherwise you need to create a hash as follows: "hour" = & gt; {"day" => "Sunday", "open_time" => 6 "," close_time "= & gt; 6)}} < / Pre> Hope this helps :)
Comments
Post a Comment