I have a problem with has_many relationship and nested attributes
class WorkOrder < ActiveRecord::Base has_many :services,:order=> :row,:dependent => :destroy belongs_to :car belongs_to :company belongs_to :service_offer belongs_to :user_rank, :class_name => 'Rank',:foreign_key => 'user_rank_id' belongs_to :company_rank,:class_name =>'Rank', :foreign_key => 'company_rank_id
accepts_nested_attributes_for :services .... end
class Service < ActiveRecord::Base has_many :material_services, :order =>:row belongs_to :service_type belongs_to :work_order acts_as_list :scope=> "work_order_id",:column=>:row has_and_belongs_to_many :tasks attr :rows_id,true
accepts_nested_attributes_for :material_services
end
class MaterialService < ActiveRecord::Base belongs_to :service acts_as_list :scope=> "service_id" ,:column=>:row belongs_to :material_service_type
accepts_nested_attributes_for :material_service_type
end
I have WorkOrder that has_many Services and Services has_many MaterialServices...but I get an error when try to create a services through WorkOrder
wo = WorkOrder.new wo.services.build that throw wrong number of arguments (1 for 0)
but if I run s = Service.new ms = s.material_services.build That works perfect... I tried to debug the ActiveRercord but was imposible for me I just can't see what I have different between WorkOrder and Service relationship and Service and MaterialServices.
Any help is very usefull
Thanks