class Person < ActiveRecord::Base
def save
'already defined by Active Record'
end
end
Person.instance_method_already_implemented?(:save)
# => ActiveRecord::DangerousAttributeError: save is defined by Active Record. Check to make sure that you don't have an attribute or method with the same name.
Person.instance_method_already_implemented?(:name)
# => false

# File activerecord/lib/active_record/attribute_methods.rb, line 89definstance_method_already_implemented?(method_name)
ifdangerous_attribute_method?(method_name)
raiseDangerousAttributeError, "#{method_name} is defined by Active Record. Check to make sure that you don't have an attribute or method with the same name."endifsuperclass==Basesuperelse# If ThisClass < ... < SomeSuperClass < ... < Base and SomeSuperClass# defines its own attribute method, then we don't want to overwrite that.defined = method_defined_within?(method_name, superclass, Base) &&!superclass.instance_method(method_name).owner.is_a?(GeneratedAttributeMethods)
defined||superendend