Module: Guts::MultisiteConcern
- Extended by:
- ActiveSupport::Concern
- Included in:
- ApplicationController
- Defined in:
- app/concerns/guts/multisite_concern.rb
Overview
Controller concern for multisite into application
Instance Method Summary collapse
-
#current_site ⇒ Object?
Sets the current site based on the request host.
-
#with_current_site ⇒ Object
Wraps all actions to set current site for multisite.
Instance Method Details
#current_site ⇒ Object?
Sets the current site based on the request host
12 13 14 |
# File 'app/concerns/guts/multisite_concern.rb', line 12 def current_site @current_site ||= Site.find_by(domain: request.host) end |
#with_current_site ⇒ Object
Note:
This is a ‘around_action` method
Wraps all actions to set current site for multisite
19 20 21 22 23 24 25 26 27 |
# File 'app/concerns/guts/multisite_concern.rb', line 19 def with_current_site # Get the current site and begin action Site.current_id = current_site.try(:id) yield ensure # Clean up the current site ID Site.current_id = nil end |