Skip to content

Instantly share code, notes, and snippets.

@mkdynamic
Created September 4, 2010 06:22
Show Gist options
  • Save mkdynamic/564958 to your computer and use it in GitHub Desktop.
Save mkdynamic/564958 to your computer and use it in GitHub Desktop.
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