Method: Mongoid::Fields::ClassMethods#attribute_names

Defined in:
lib/mongoid/fields.rb

#attribute_namesArray<String>

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

Provides the field names in an ORM-agnostic way. Rails v3.1+ uses this method to automatically wrap params in JSON requests.

Examples:

Get the field names

Model.attribute_names

Returns:

  • (Array<String>)

    The field names



454
455
456
# File 'lib/mongoid/fields.rb', line 454

def attribute_names
  fields.keys
end