Created
March 16, 2012 07:18
-
-
Save avakhov/2048989 to your computer and use it in GitHub Desktop.
alias_method_chain
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 Role < ActiveRecord::Base | |
belongs_to :user | |
end |
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 | |
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