Sha256: 5f0a3ba09c38523a4f0303074380bd7d460eabc0c37c0ed0161323f334ed485a

Contents?: true

Size: 999 Bytes

Versions: 18

Compression:

Stored size: 999 Bytes

Contents

module Workarea
  class ApplicationController < ActionController::Base
    include I18n::DefaultUrlOptions
    include HttpCaching
    include CurrentTracking
    include CurrentSegments

    protect_from_forgery

    after_action :set_flash_header

    # Cache templates within the scope of a request for development
    if Rails.env.development?
      prepend_before_action { ActionView::Resolver.caching = true }
      after_action { ActionView::Resolver.caching = false }
    end

    helper_method :current_location
    helper :local_time

    def default_url_options(*)
      super.merge(host: Workarea.config.host)
    end

    def current_location
      current_visit.geolocation
    end

    def view_model_options
      params.to_unsafe_h
    end

    private

    def set_flash_header
      messages = flash.map { |k, v| [k, ERB::Util.h(v)] }
      response.headers['X-Flash-Messages'] = Hash[messages].to_json
      flash.discard if request.xhr? && !response.redirect?
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/controllers/workarea/application_controller.rb
workarea-core-3.5.26 app/controllers/workarea/application_controller.rb
workarea-core-3.5.25 app/controllers/workarea/application_controller.rb
workarea-core-3.5.23 app/controllers/workarea/application_controller.rb
workarea-core-3.5.22 app/controllers/workarea/application_controller.rb
workarea-core-3.5.21 app/controllers/workarea/application_controller.rb
workarea-core-3.5.20 app/controllers/workarea/application_controller.rb
workarea-core-3.5.19 app/controllers/workarea/application_controller.rb
workarea-core-3.5.18 app/controllers/workarea/application_controller.rb
workarea-core-3.5.17 app/controllers/workarea/application_controller.rb
workarea-core-3.5.16 app/controllers/workarea/application_controller.rb
workarea-core-3.5.15 app/controllers/workarea/application_controller.rb
workarea-core-3.5.14 app/controllers/workarea/application_controller.rb
workarea-core-3.5.13 app/controllers/workarea/application_controller.rb
workarea-core-3.5.12 app/controllers/workarea/application_controller.rb
workarea-core-3.5.11 app/controllers/workarea/application_controller.rb
workarea-core-3.5.10 app/controllers/workarea/application_controller.rb
workarea-core-3.5.9 app/controllers/workarea/application_controller.rb