module ActiveRecord::AttributeMethods::ClassMethods

def attribute_names

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

end
class Person < ActiveRecord::Base

table exists. Otherwise it returns an empty array.
Returns an array of column names as strings if it's not an abstract class and
def attribute_names
  @attribute_names ||= if !abstract_class? && table_exists?
      column_names
    else
      []
    end
end