Module: ActiveModelPersistence::PrimaryKey::ClassMethods
- Defined in:
- lib/active_model_persistence/primary_key.rb
Overview
When this module is included in another class, ActiveSupport::Concern will make these class methods on that class.
Instance Method Summary collapse
-
#primary_key ⇒ Symbol
Identifies the attribute that the ‘primary_key` accessor maps to.
-
#primary_key=(attribute) ⇒ void
Sets the attribute to use for the primary key.
Instance Method Details
#primary_key ⇒ Symbol
Identifies the attribute that the ‘primary_key` accessor maps to
The primary key is ‘id’ by default.
59 60 61 |
# File 'lib/active_model_persistence/primary_key.rb', line 59 def primary_key @primary_key ||= 'id' end |
#primary_key=(attribute) ⇒ void
This method returns an undefined value.
Sets the attribute to use for the primary key
78 79 80 |
# File 'lib/active_model_persistence/primary_key.rb', line 78 def primary_key=(attribute) @primary_key = attribute.to_s end |