Created
June 23, 2014 16:21
-
-
Save Martin91/d1d19f0017f379e73eb5 to your computer and use it in GitHub Desktop.
habtm: collection.build doesn't build join associations (unlike collection.create)
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
@user = User.first | |
@project = @user.projects.build(:name => "Make your bed") | |
# if you do @project.save here, as in the gist, | |
# association will not be saved, but if you do : | |
@user.save | |
# it will save the @user with its associated projects |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment