28 lines
693 B
Ruby
28 lines
693 B
Ruby
module Dunlop
|
|
class ApplicationController < ::ApplicationController
|
|
layout 'application'
|
|
|
|
before_action :store_or_reset_params_q, only: :index
|
|
|
|
private
|
|
|
|
def query
|
|
params[:q]
|
|
end
|
|
|
|
def store_or_reset_params_q
|
|
session_key = "#{controller_path}_q"
|
|
session[session_key] = nil if params[:reset_q].present?
|
|
params[:q] = session[session_key] if params[:q].blank?
|
|
current_query = (params[:q] || {}).select{|k,v | v.present? }
|
|
session[session_key] = current_query if params[:q].present?
|
|
end
|
|
|
|
if Rails::VERSION::MAJOR < 5
|
|
def redirect_back(fallback_location:, **args)
|
|
redirect_to :back, args
|
|
end
|
|
end
|
|
end
|
|
end
|