Wednesday, 14 August 2013

Create related objects after initialize another object in rails

Create related objects after initialize another object in rails

I have the below models:
class Foo < ActiveRecord::Base
has_many :bars
end
class Bar < ActiveRecord::Base
belongs_to :foo
end
In the business logic, when initializing an object foo f = Foo.new three
bars need to be initialized, too. How can I do this?

No comments:

Post a Comment