[Rails] Building Assocation with multiple belong_tos
Hello,
I have two models that look like the following:
ModelA:
attr_accessible :date, ...
has_many :modelb
accepts_nested_attributes_for :modelb
end
ModelB:
attr_accessible :date, ...
belongs_to :modela, :modelc, :modeld
end
And then in ModelAs controller:
@modela = Modela.new
3.times do |i|
@modela.modelb.build(:date => Time.now)
end
When ModelB has 3 belongs_to and I attempt to build the association with just ModelA I get the following error:
ArgumentError wrong number of arguments (3 for 2)
When ModelB just belongs_to modela it works. Do I need to somehow setup a fake association for the other belong_tos? Those are to be created in the UI by the user.
Thanks,
Jarod
-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Gv5tkWCmhlQJ.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home