Skip to content

Instantly share code, notes, and snippets.

@avakhov
Created March 16, 2012 07:18
Show Gist options
  • Save avakhov/2048989 to your computer and use it in GitHub Desktop.
Save avakhov/2048989 to your computer and use it in GitHub Desktop.
alias_method_chain
class Role < ActiveRecord::Base
belongs_to :user
end
class User < ActiveRecord::Base
has_many :roles
accepts_nested_attributes_for :roles
# Работает!
# [begin]
def roles_attributes=(value)
ActiveRecored::Base.logger.info "123"
self.roles_attributes_without_saving=(value)
end
alias_method_chain :roles_attributes=, :saving
# [end]
# Не работает!
# [begin]
def roles_attributes=(value)
ActiveRecored::Base.logger.info "123"
super # NoMethodError: super: no superclass method `roles_attributes=' for
end
# [end]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment