I have an issue when trying to save attributes to a join model. I get an error: wrong number of arguments (0 for 1..2)

I have implemented this before without problem in other apps so it is extra confusing where I am going wrong.

I have the following models:

class Product < ActiveRecord::Base has_attached_file :product_image, :styles => { :medium => "250x250>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png" validates_attachment_content_type :product_image, :content_type => /\Aimage\/.*\Z/ has_many :package_items has_many :packages, through: :package_items end

--

class PackageItem < ActiveRecord::Base belongs_to :package belongs_to :product end

--

class Package < ActiveRecord::Base has_attached_file :package_image, :styles => { :medium => "200x200>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png" validates_attachment_content_type :package_image, :content_type => /\Aimage\/.*\Z/ has_many :package_items has_many :products, through: :package_items end

When I save a package it should save all the products that the package contains in the package_items table. I am using the collection_check_boxes helper in my form and this is working fine.

<%= form_for @package, :url => packages_path, :html => { :multipart => true } do |f| %> <% if @package.errors.any? %> <div id="error_explanation" class="center"> <h2><%= pluralize(@package.errors.count, "error") %> prohibited this package from being saved:</h2> <ul> <% @package.errors.full_messages.each do |message| %> <li><%= message %></li> <% end %> </ul> </div> <% end %> <div class="col-xs-12 field"> <%= f.label :name, 'Package Name', :class => "text-center form-header" %><br> <%= f.text_field :name, :class => "text-center form-text" %> </div> <br> <br> <br> <div class="col-xs-12 field"> <%= f.label :package_image, 'Package Image', :class => "text-center form-header" %><br> <%= f.file_field :package_image %> </div> <br> <br> <br> <div class="col-xs-12 field"> <%= f.label :price, 'Price Per Day', :class => "text-center form-header" %><br> <%= f.number_field :price, :class => "text-center form-text" %> </div> <br> <br> <div class="col-xs-12 field"> <%= f.label :products %><br> <%= f.collection_check_boxes :product_ids, Product.all, :id, :name, {}, { :multiple => true } %> </div> <br> <br> <div class="col-xs-12 actions"> <%= f.submit %> </div> <% end %>

However when I submit the form I get the wrong number of arguments (0 for 1..2) error with it highlighting my strong params method in the packages controller:

def package_params params.require(:package).permit(:name, :price, :package_image, :product_ids []) end

I cannot see anything obvious in the logs. Any pointers would be much appreciated. It feels like I have gone through all of the web and SO at this stage and I can't get past this. Essentially what I am trying to achieve is the same as this SO post.