Class: Lesli::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/lesli/application_controller.rb

Direct Known Subclasses

ApplicationLesliController

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplicationController

Returns a new instance of ApplicationController.



40
41
42
43
# File 'app/controllers/lesli/application_controller.rb', line 40

def initialize
    super
    @lesli = {}
end

Instance Attribute Details

#engine_pathObject (readonly)

Returns the value of attribute engine_path.



38
39
40
# File 'app/controllers/lesli/application_controller.rb', line 38

def engine_path
  @engine_path
end

#queryObject (readonly)

Returns the value of attribute query.



37
38
39
# File 'app/controllers/lesli/application_controller.rb', line 37

def query
  @query
end

Instance Method Details

#languageObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/controllers/lesli/application_controller.rb', line 45

def language

    # check if param locale was sent by the user
    unless params[:locale].blank?

        locale = params[:locale].to_sym

        # check if locale requested is valid
        if I18n.available_locales.include?(locale)

            # save requested locale in session
            # this will be used in application_controller#switch_locale
            session[:locale] = locale

        end

    end

    I18n.locale = locale

    redirect_back(fallback_location: request.referer)

    # This code is not really executed
    # respond_with_successful({
    #                             locale: I18n.locale,
    #                             default_locale: I18n.default_locale,
    #                             available_locales: I18n.available_locales
    #                         })
end