i have an url of: party_detail_search/search but the url of [party_detail_search/search?breadcrumbs] and [party_detail_search/search?adycfaf] also redirected to party_detail_search/search with the same web contents...i don't want the duplicate pages, how do i solve this problem
CodePudding user response:
if you want both the urls:
party_detail_search/search?breadcrumbs
party_detail_search/search?adycfaf
to go to same place, then you can define a route in config/routes.rb as follows
get 'party_detail_search/search' => 'some_controller#some_action'
in 'some_controller' you can define 'some_action'. If you also want the the word after the '?' this is passed as a nil value parameter, named 'breadcrumbs' or 'adycfaf' respectively e.g. { 'breadcrumbs' => nil }
the example 'search_parameter' method will extract it from the params hash.
class SomeController < ApplicationController
def some_action
..do stuff
end
private
def search_parameter
params.collect{ |key, value| key if value.nil? }.compact.first
end
end