Created
September 4, 2010 06:22
-
-
Save mkdynamic/564958 to your computer and use it in GitHub Desktop.
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
class User < ActiveRecord::Base | |
end | |
# doesn't work: | |
class Item < ActiveRecord::Base | |
belongs_to :user | |
accepts_nested_attributes_for :user | |
end | |
# does work: | |
class Item < ActiveRecord::Base | |
belongs_to :user | |
def user_attributes=(attrs) | |
@user_attributes = attrs | |
end | |
after_save :update_user_attributes | |
def update_user_attributes | |
user.update_attributes! @user_attributes | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment