method
has_attribute?
v8.0.0 -
Show latest stable
- Class:
ActiveRecord::AttributeMethods::ClassMethods
has_attribute?(attr_name)public
Returns true if the given attribute exists, otherwise false.
class Person < ActiveRecord::Base alias_attribute :new_name, :name end Person.has_attribute?('name') # => true Person.has_attribute?('new_name') # => true Person.has_attribute?(:age) # => true Person.has_attribute?(:nothing) # => false