Last active
January 1, 2016 05:38
-
-
Save jaz303/8099432 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo < ActiveRecord::Base | |
has_many :foo_bars | |
has_many :bars, :through => :foo_bars | |
end | |
class Bar < ActiveRecord::Base | |
end | |
class FooBar < ActiveRecord::Base | |
belongs_to :foo | |
belongs_to :bar | |
end | |
old_foo = Foo.find(id) | |
new_foo = Foo.create | |
# will attributes on the join models (FooBar) be copied or | |
# will they assume their default values? | |
new_foo.bars = old_foo.bars |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment