multiple insert - one form

7 views
Skip to first unread message

Werner

unread,
Jul 16, 2013, 11:50:54 AM7/16/13
to rubyonra...@googlegroups.com
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


Reply all
Reply to author
Forward
0 new messages