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"]
186 187 188 189 190 191 192 |
# File 'lib/active_record/attribute_methods.rb', line 186 def attribute_names @attribute_names ||= if !abstract_class? && table_exists? column_names else [] end end |