instance method attribute_names

Ruby on Rails 6.0.6

Since v6.0.6

Available in: v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

attribute_names()

Returns an array of attribute names as strings

class Person
  include ActiveModel::Attributes

  attribute :name, :string
  attribute :age, :integer
end

Person.attribute_names
# => ["name", "age"]
Source
# File activemodel/lib/active_model/attributes.rb, line 40
      def attribute_names
        attribute_types.keys
      end

Defined in activemodel/lib/active_model/attributes.rb line 40 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveModel::Attributes::ClassMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close