# class ApplicationController

START:i18n

### Protected Instance Methods

authorize() click to toggle source

END:i18n

    # File app/controllers/application_controller.rb, line 19
    def authorize
      if request.format == Mime::HTML
        unless User.find_by(id: session[:user_id])
          redirect_to login_url, notice: "Please log in"
        end
      else
        authenticate_or_request_with_http_basic do |username, password|
          user = User.find_by(name: username)
          user && user.authenticate(password)
        end
      end
    end

default_url_options() click to toggle source

    # File app/controllers/application_controller.rb, line 46
    def default_url_options
      { locale: I18n.locale }
    end

set_i18n_locale_from_params() click to toggle source

    # File app/controllers/application_controller.rb, line 34
    def set_i18n_locale_from_params
      if params[:locale]
        if I18n.available_locales.include?(params[:locale].to_sym)
          I18n.locale = params[:locale]
        else
          flash.now[:notice] =
            "#{params[:locale]} translation not available"
          logger.error flash.now[:notice]
        end
      end
    end