Ruby on Rails Friday, December 12, 2014

{"utf8"=>"✓",
"authenticity_token"=>"fB/ZNf3dnFz9OVa/h34xbNysN0AlxcIiPs=",
"f"=>[{"columns_id"=>"4",
"column_value"=>"rrr",
"users_id"=>"2"},
{"columns_id"=>"5",
"column_value"=>"ttt",
"users_id"=>"2"}],
"commit"=>"Save changes"}


I want to store object values but how to store multiple record at same
time using controller.

my controller code -

def create
params[:f].each do |user_params|
Detail.new(user_params).save
end
end


my view code -

<%= form_for(:detail, :url => {:controller => 'details', :action =>
'create'}) do %>
<% @info.each do |article| %>
<%= hidden_field_tag "f[][columns_id]", article.id %>
<p>
<td><%= article.value %></td>
<td><%= text_field_tag "f[][column_value]" %></td>
</p></br>
<%= hidden_field_tag "f[][users_id]", current_user.id %>
<% end %>
<p class="button"><%= submit_tag %></p>
<% end %>

Its gives error ActiveModel::ForbiddenAttributesError how to solve
please help me

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b5bd89432a87af113ee994f23d0a8c96%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment