Module: ModelTimeline::ControllerAdditions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/model_timeline/controller_additions.rb
Overview
Provides controller functionality for automatically tracking model timeline information. When included in a controller, this module will capture the current user and IP address for each request and make them available for timeline entries.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#clear_model_timeline_info ⇒ void
Clears the request store after the request is complete.
-
#set_model_timeline_info ⇒ void
Sets the current user and IP address in the request store.
Instance Method Details
#clear_model_timeline_info ⇒ void
This method returns an undefined value.
Clears the request store after the request is complete. Called automatically as an after_action.
50 51 52 |
# File 'lib/model_timeline/controller_additions.rb', line 50 def clear_model_timeline_info ModelTimeline.clear_request_store end |
#set_model_timeline_info ⇒ void
This method returns an undefined value.
Sets the current user and IP address in the request store. Called automatically as a before_action.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/model_timeline/controller_additions.rb', line 30 def set_model_timeline_info user = (send(ModelTimeline.current_user_method) if respond_to?(ModelTimeline.current_user_method, true)) ip = begin if request.respond_to?(ModelTimeline.current_ip_method) request.send(ModelTimeline.current_ip_method) else request.remote_ip end rescue StandardError nil end ModelTimeline.store_user_and_ip(user, ip) end |