[Rails] multiple insert - one form
I am stuck extending my formular.
There is a list of users with a checkbox. Submitting the form creates new entires depending on which check_box was clicked.
I want to include another attribute, (#new) but dont know how to do it.
View:
<%= form_tag some_path, :method => :post do %>
<% @users.each do |user| %>
<%= check_box_tag "user_ids[]", "#{user.id}" %>
<%= hidden_field_tag(:instruction_id, "#{@instruction.id}") %>
#new <%= select_tag :prio, options_for_select(1..5, 1) %> #new
<% end %>
Controller
@users = User.all
@instruction = Instruction.find(params[:id])
params[:user_ids].each do | user |
Model.create(
:user_id => user, :instruction_id => params[:instruction_id]
)
end
Help would be great..Do I have to use form_field?
Werner
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/eac5d8ee-76fd-4940-ad0a-36ee3e1fe4bc%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home