Method: ActiveRecord::AttributeMethods#attribute_names

Defined in:
activerecord/lib/active_record/attribute_methods.rb

#attribute_namesObject

Returns an array of names for the attributes available on this object.

class Person < ActiveRecord::Base
end

person = Person.new
person.attribute_names
# => ["id", "created_at", "updated_at", "name", "age"]


334
335
336
# File 'activerecord/lib/active_record/attribute_methods.rb', line 334

def attribute_names
  @attributes.keys
end