module ActiveRecord::AttributeMethods::ClassMethods
def has_attribute?(attr_name)
Person.has_attribute?(:age) # => true
Person.has_attribute?('new_name') # => true
Person.has_attribute?('name') # => true
end
alias_attribute :new_name, :name
class Person < ActiveRecord::Base
Returns true if the given attribute exists, otherwise false.
def has_attribute?(attr_name) attr_name = attr_name.to_s attr_name = attribute_aliases[attr_name] || attr_name attribute_types.key?(attr_name) end