Skip to content

Instantly share code, notes, and snippets.

@miry
Created June 24, 2009 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miry/135350 to your computer and use it in GitHub Desktop.
Save miry/135350 to your computer and use it in GitHub Desktop.
Create several associations at once
class User < ActiveRecord::Base
has_many :cars
end
class Car < ActiveRecord::Base
belongs_to :user
end
User.first.cars.build([{}, {}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment