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

Instance Method Details

#current_siteObject?

Sets the current site based on the request host

Returns:

  • (Object, nil)

    the current site if found or nil



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_siteObject

Note:

This is a ‘around_action` method

Wraps all actions to set current site for multisite

See Also:



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