Method: ActiveRecord::AttributeMethods::ClassMethods#attribute_names
- Defined in:
- lib/active_record/attribute_methods.rb
#attribute_names ⇒ Object
Returns an array of column names as strings if it’s not an abstract class and table exists. Otherwise it returns an empty array.
class Person < ActiveRecord::Base
end
Person.attribute_names
# => ["id", "created_at", "updated_at", "name", "age"]
162 163 164 165 166 167 168 |
# File 'lib/active_record/attribute_methods.rb', line 162 def attribute_names @attribute_names ||= if !abstract_class? && table_exists? attribute_types.keys else [] end end |