method

has_attribute?

Importance_1
Ruby on Rails latest stable (v7.1.3.2) - 0 notes - 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
Show source
Register or log in to add new notes.