Class: BlacklightAdvancedSearch::RedirectLegacyParamsFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/blacklight_advanced_search/redirect_legacy_params_filter.rb

Class Method Summary collapse

Class Method Details

.before(controller) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/blacklight_advanced_search/redirect_legacy_params_filter.rb', line 11

def self.before(controller)
  params = controller.send(:params)

  if params[:f_inclusive] && params[:f_inclusive].respond_to?(:each_pair)
    legacy_converted = false

    params[:f_inclusive].each_pair do |field, value|
      next unless value.is_a? Hash
      # old style! convert!
      legacy_converted = true
      params[:f_inclusive][field] = value.keys
    end

    if legacy_converted
      controller.send(:redirect_to, params, :status => :moved_permanently)
    end
  end
end