Sha256: d4390bd7c308ec384d40ec416b62bdbd8557167c48bfe7ae5def6eb5ff4ee9b5
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 KB
Contents
module Dorsale module SmallData class FiltersController < ::Dorsale::ApplicationController def create new_filters = params.fetch(:filters, {}).permit!.to_h new_filters.each do |key, value| new_filters[key] = "" if value == "0" end filters = Filter.new(cookies) new_filters = filters.read.merge(new_filters) filters.store(new_filters) # Rewrite cookie with 1 year expiry cookies[:filters] = { :value => cookies[:filters], :expires => 1.year.from_now, :path => "/", } redirect_to back_url end def back_url urls = [ params[:back_url], request.referer, (main_app.root_path rescue nil) ] url = urls.select(&:present?).first # Delete page page 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? url = base + query_string url end end end end
Version data entries
3 entries across 3 versions & 1 rubygems