Created
August 12, 2012 02:42
-
-
Save synth/3329212 to your computer and use it in GitHub Desktop.
weird rails association behavior
This file contains 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
$> rails new mynewapp | |
$> cd mynewapp | |
$> rails g model User | |
$> rails g model Whatever | |
$> rake db:migration | |
#user.rb | |
belongs_to :whatever | |
$> rails c | |
u = User.new | |
u.save | |
w = Whatever.new | |
w.save | |
u.whatever = w | |
u.save #no error! | |
u.whatever #=> w(Whatever) | |
u.reload #=> w(Whatever) | |
User.find(u.id).whatever #=> nil!!!!!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment