Skip to content

Instantly share code, notes, and snippets.

@mehlah
Last active November 29, 2015 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehlah/81f0351b1e761d88800b to your computer and use it in GitHub Desktop.
Save mehlah/81f0351b1e761d88800b to your computer and use it in GitHub Desktop.
Alias Method Chain
require 'active_support/all'
class Record
def save
p 'saved!'
end
def save_with_validation
p 'validated!'
save_without_validation
end
alias_method_chain :save, :validation
end
Record.new.save
#=> "validated!"
#=> "saved!"
Record.new.save_without_validation
#=> "saved!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment