module Spree::Core::ControllerHelpers::Common

Attributes

title[W]

can be used in views as well as controllers. e.g. <% self.title = 'This is a custom title for this view' %>

Protected Instance Methods

accurate_title() click to toggle source

this is a hook for subclasses to provide title

# File lib/spree/core/controller_helpers/common.rb, line 44
def accurate_title
  current_store.seo_title
end
default_title() click to toggle source
# File lib/spree/core/controller_helpers/common.rb, line 39
def default_title
  current_store.name
end
title() click to toggle source
# File lib/spree/core/controller_helpers/common.rb, line 26
def title
  title_string = @title.present? ? @title : accurate_title
  if title_string.present?
    if Spree::Config[:always_put_site_name_in_title]
      [title_string, default_title].join(' - ')
    else
      title_string
    end
  else
    default_title
  end
end

Private Instance Methods

get_layout() click to toggle source

Returns which layout to render.

You can set the layout you want to render inside your Spree configuration with the :layout option.

Default layout is: app/views/spree/layouts/spree_application

# File lib/spree/core/controller_helpers/common.rb, line 76
def get_layout
  Spree::Config[:layout]
end
set_user_language() click to toggle source
# File lib/spree/core/controller_helpers/common.rb, line 54
def set_user_language
  available_locales = Spree.i18n_available_locales
  locale = [
    params[:locale],
    session[set_user_language_locale_key],
    (config_locale if respond_to?(:config_locale, true)),
    I18n.default_locale
  ].detect do |candidate|
    candidate &&
      available_locales.include?(candidate.to_sym)
  end
  session[set_user_language_locale_key] = locale
  I18n.locale = locale
  Carmen.i18n_backend.locale = locale
end
set_user_language_locale_key() click to toggle source
# File lib/spree/core/controller_helpers/common.rb, line 50
def set_user_language_locale_key
  :locale
end