module ActiveRecord::AttributeMethods

def has_attribute?(attr_name)

person.has_attribute?(:nothing) # => false
person.has_attribute?('age') # => true
person.has_attribute?(:new_name) # => true
person.has_attribute?(:name) # => true
person = Person.new

end
alias_attribute :new_name, :name
class Person < ActiveRecord::Base

Returns +true+ if the given attribute is in the attributes hash, otherwise +false+.
def has_attribute?(attr_name)
  attr_name = attr_name.to_s
  attr_name = self.class.attribute_aliases[attr_name] || attr_name
  @attributes.key?(attr_name)
end