I have 4 models
class Contract < ActiveRecord::Base
has_many :addendums
accepts_nested_attributes_for :addendums
end
class Addendum < ActiveRecord::Base
belongs_to :contract
has_many :addendum_services
has_many :services, through: :addendum_services
end
class AddendumService < ActiveRecord::Base
belongs_to :addendum
belongs_to :service
end
class Service < ActiveRecord::Base
has_many :addendum_services
end
I'm using nested attributes to build the addendum through the Contract's form and it's working for all the Addendum's attributes but I also want the user to chose, using the check_box_tag, the list of Services to use. Since the Addendum does not have an attribute for addendum_services, what should I add to the Contract's strong params in order to accept the Service list? Also, how can I generate the list of services on the form? i'm currently using this:
<%= form_for(@contract) do |f| %>
...
<%= f.fields_for :addendums do |addendums_form|%>
<%= addendums_form.label 'Services'%><br>
<% for serv in Service.all %>
<%= check_box_tag "service[]", serv, @addendum.services.include?(serv) %>
<%= serv %><br>
<% end %>
but it's not working...