This form:
<%= form_tag({:controller => "smart_lists", :action => "create"}, class: 'form-inline', :method => "POST") do %>
<%= label_tag :name %>
<%= text_field_tag :name %><br><br>
<% @people.each do |person| %>
<%= check_box_tag 'people_id[]', id: person.id %><%= label_tag person.name %><br>
<% end %>
<%= submit_tag "Create", class: 'btn' %>
Sends its check box list to a controller here:
def create
@smart_list = SmartList.new(params[:smart_list])
@smart_list.name = params[:name]
@smart_list.people = params[:people_id]
etc....
And I end up with this in my logs:
"name"=>"This is not working : (", "people_id"=>["{:id=>64}", "{:id=>8}", "{:id=>1}"]
And this in my view:
Person(#70133507313700) expected, got String(#70133469090180)
So, I guess my question is - Is there a way to break the that stuff out of those strings? Or can I send them through the form in a better way? Or catch them a better way in the controller?
Thanks for your help - Joey
I ended up changing the check_box_tag in the form to:
Which gave me something like this in my params:
And then in the controller I looped through the :people params and took out the ids:
I feel like this is pretty ugly - but it works. If anyone has a better way to form the view or controller I would still like to know a better way to do this. - Thanks