Sha256: 92e622468940c502c0e4742a614601305fe7b5e7db0a768925f62c358629b9ad

Contents?: true

Size: 968 Bytes

Versions: 18

Compression:

Stored size: 968 Bytes

Contents

class Agilibox::SmallData::FiltersController < ::Agilibox::ApplicationController
  def create
    skip_authorization if respond_to?(:skip_authorization)
    skip_policy_scope  if respond_to?(:skip_policy_scope)

    filters = ::Agilibox::SmallData::Filter.new(cookies)
    new_filters = params.fetch(:filters, {}).permit!.to_h
    filters.merge new_filters

    # Rewrite cookie with 1 year expiry
    cookies[:filters] = {
      :value   => cookies[:filters],
      :expires => 1.year.from_now,
      :path    => "/",
    }

    redirect_to back_url
  end

  private

  def back_url
    url = [
      params[:form_url],
      request.referer,
      main_app.try(:root_path),
      "/",
    ].find(&:present?)

    # Delete page param
    base, query_string = url.split("?")
    query_string = query_string.to_s.split("&").delete_if { |p| p.include?("page=") }.join("&")
    query_string = "?#{query_string}" if query_string.present?
    base + query_string
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
agilibox-1.3.6 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.3.5 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.3.4 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.3.3 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.3.2 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.3.1 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.3.0 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.2.3 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.2.2 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.2.1 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.2.0 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.1.0 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.0.15 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.0.14 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.0.13 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.0.12 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.0.11 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.0.10 app/controllers/agilibox/small_data/filters_controller.rb