Check Boxes Helper and has_many_through Association

32 views
Skip to first unread message

Pedr Browne

unread,
Jun 5, 2013, 12:21:52 PM6/5/13
to plataformate...@googlegroups.com
Hello,

I'm having difficulties with the collection_check_boxes helper with a has_many_through association. I have an ArchiveResource that has_many Regions through Regional. In my ArchiveResourcesController#new view, I am usng the helper to allow regions to be added to a created ArchiveResource.

    <%= f.collection_check_boxes :region_ids, Region.all, :id, :name %>

This generates a form with checkboxes for each of my regions. However, on submission I receive an error:

ActiveRecord::MultiparameterAssignmentErrors - 1 error(s) on assignment of multiparameter attributes:
activerecord (3.2.13) lib/active_record/attribute_assignment.rb:144:in `execute_callstack_for_multiparameter_attributes'
activerecord (3.2.13) lib/active_record/attribute_assignment.rb:122:in `assign_multiparameter_attributes'
activerecord (3.2.13) lib/active_record/attribute_assignment.rb:98:in `assign_attributes'
activerecord (3.2.13) lib/active_record/base.rb:498:in `initialize'
app/controllers/archive_resources_controller.rb:54:in `create'


My params look OK:

{"utf8"=>"✓", "archive_resource"=>{"name"=>"Example Name", "summary"=>"Example summary.", "cost"=>"1", "year(1i)"=>"2013", "year(2i)"=>"6", "year(3i)"=>"5", "region_ids"=>["1", "2", ""]}, "commit"=>"Create", "action"=>"create", "controller"=>"archive_resources"}

Can anyone suggest where the problem might lie?

Fabiano Almeida

unread,
Jun 5, 2013, 1:44:40 PM6/5/13
to plataformate...@googlegroups.com
Hi Pedr,

Could you show your models? I think, after research it, this error could be related to attr_accessible



--
You received this message because you are subscribed to the Google Groups "SimpleForm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to plataformatec-simp...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Fabiano Almeida

javinto

unread,
Jun 6, 2013, 3:44:39 AM6/6/13
to plataformate...@googlegroups.com
That's correct, you should have :region_ids in your attr_accessible list of your archive_resource model.


Op woensdag 5 juni 2013 18:21:52 UTC+2 schreef Pedr Browne het volgende:
Reply all
Reply to author
Forward
0 new messages