Sha256: ce85ff0b683014c3d6dde2d676da0568c5bd3ac0fec17a40bce74cb27c4c5b44

Contents?: true

Size: 1.78 KB

Versions: 22

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

module Decidim
  # The main application controller that inherits from Rails.
  class ApplicationController < ::DecidimController
    include NeedsOrganization
    include LocaleSwitcher
    include NeedsAuthorization
    include PayloadInfo
    include ImpersonateUsers

    helper Decidim::MetaTagsHelper
    helper Decidim::DecidimFormHelper
    helper Decidim::LanguageChooserHelper
    helper Decidim::ReplaceButtonsHelper
    helper Decidim::TranslationsHelper
    helper Decidim::CookiesHelper
    helper Decidim::AriaSelectedLinkToHelper
    helper Decidim::MenuHelper
    helper Decidim::FeaturePathHelper

    # Saves the location before loading each page so we can return to the
    # right page. If we're on a devise page, we don't want to store that as the
    # place to return to (for example, we don't want to return to the sign in page
    # after signing in), which is what the :unless prevents
    before_action :store_current_location, unless: :devise_controller?

    protect_from_forgery with: :exception, prepend: true
    after_action :add_vary_header

    layout "layouts/decidim/application"

    private

    def store_current_location
      store_location_for(:user, request.url)
    end

    def user_not_authorized_path
      decidim.root_path
    end

    # Make sure Chrome doesn't use the cache from a different format. This
    # prevents a bug where clicking the back button of the browser
    # displays the JS response instead of the HTML one.
    def add_vary_header
      response.headers["Vary"] = "Accept"
    end

    # Overwrites `cancancan`'s method to point to the correct ability class,
    # since the gem expects the ability class to be in the root namespace.
    def current_ability_klass
      Decidim::Abilities::BaseAbility
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
decidim-core-0.6.8 app/controllers/decidim/application_controller.rb
decidim-0.6.8 decidim-core/app/controllers/decidim/application_controller.rb
decidim-core-0.6.7 app/controllers/decidim/application_controller.rb
decidim-0.6.7 decidim-core/app/controllers/decidim/application_controller.rb
decidim-core-0.6.6 app/controllers/decidim/application_controller.rb
decidim-0.6.6 decidim-core/app/controllers/decidim/application_controller.rb
decidim-core-0.6.5 app/controllers/decidim/application_controller.rb
decidim-0.6.5 decidim-core/app/controllers/decidim/application_controller.rb
decidim-core-0.6.4 app/controllers/decidim/application_controller.rb
decidim-0.6.4 decidim-core/app/controllers/decidim/application_controller.rb
decidim-core-0.6.3 app/controllers/decidim/application_controller.rb
decidim-0.6.3 decidim-core/app/controllers/decidim/application_controller.rb
decidim-core-0.6.2 app/controllers/decidim/application_controller.rb
decidim-0.6.2 decidim-core/app/controllers/decidim/application_controller.rb
decidim-core-0.6.1 app/controllers/decidim/application_controller.rb
decidim-0.6.1 decidim-core/app/controllers/decidim/application_controller.rb
decidim-core-0.6.0 app/controllers/decidim/application_controller.rb
decidim-0.6.0 decidim-core/app/controllers/decidim/application_controller.rb
decidim-core-0.5.1 app/controllers/decidim/application_controller.rb
decidim-0.5.1 decidim-core/app/controllers/decidim/application_controller.rb