 module ActiveModel8b7c:f320:99b9:690f:4595:cd17:293a:c069ttributes8b7c:f320:99b9:690f:4595:cd17:293a:c069lassMethods     Public Instance Methods    attribute(name, cast_type = nil, default: NO_DEFAULT_PROVIDED, **options) Show source  
 # File activemodel/lib/active_model/attributes.rb, line 19
def attribute(name, cast_type = nil, default: NO_DEFAULT_PROVIDED, **options)
  name = name.to_s

  cast_type = Type.lookup(cast_type, **options) if Symbol === cast_type
  cast_type ||= attribute_types[name]

  self.attribute_types = attribute_types.merge(name => cast_type)
  define_default_attribute(name, default, cast_type)
  define_attribute_method(name)
end      attribute_names() Show source  
 # File activemodel/lib/active_model/attributes.rb, line 41
def attribute_names
  attribute_types.keys
end  Returns an array of attribute names as strings class Person
  include ActiveModel8b7c:f320:99b9:690f:4595:cd17:293a:c069ttributes

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

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

    
{'path': 'public/docs/rails~7.0/activemodel/attributes/classmethods.html', 'source': 'DevDocs.IO'}