Module: ActiveRecord::Associations::UserStamps::ClassMethods
- Defined in:
- lib/active_record/associations/user_stamps.rb
Overview
Methods added to ActiveRecord::Base
Instance Method Summary collapse
-
#created_by(user_model, options = {}) ⇒ Object
Creates an association on the
created_by
column to the supplieduser_model
argument. -
#stamped_by(user_model) ⇒ Object
Creates associations for
created_by
andupdated_by
using the respective configuration of each. -
#updated_by(user_model, options = {}) ⇒ Object
Creates an association on the
updated_by
column to the supplieduser_model
argument.
Instance Method Details
#created_by(user_model, options = {}) ⇒ Object
Creates an association on the created_by
column to the supplied user_model
argument. You can override the created_by
column name with :foriegn_key but at that point you might as well set up the relationship yourself.
Required by default.
26 27 28 |
# File 'lib/active_record/associations/user_stamps.rb', line 26 def created_by user_model, = {} user_association :creator, user_model, .reverse_merge(:foreign_key => 'created_by', :required => true) end |
#stamped_by(user_model) ⇒ Object
Creates associations for created_by
and updated_by
using the respective configuration of each.
15 16 17 18 |
# File 'lib/active_record/associations/user_stamps.rb', line 15 def stamped_by user_model created_by user_model updated_by user_model end |
#updated_by(user_model, options = {}) ⇒ Object
Creates an association on the updated_by
column to the supplied user_model
argument. You can override the updated_by
column name with :foriegn_key but at that point you might as well set up the relationship yourself.
Not required by default.
36 37 38 |
# File 'lib/active_record/associations/user_stamps.rb', line 36 def updated_by user_model, = {} user_association :updator, user_model, .reverse_merge(:foreign_key => 'updated_by', :required => false) end |