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

On 12 December 2012 15:18, Jarod W. [email protected] wrote:

Hello,
I have two models that look like the following:

ModelA:
attr_accessible :date, …
has_many :modelb

That should be modelbs, plural.

accepts_nested_attributes_for :modelb
end

ModelB:
attr_accessible :date, …
belongs_to :modela, :modelc, :modeld

I think you have to specify those on separate lines.

Colin

Ah thanks Colin, that was it!