Reputation: 7043
I am trying to do a 301 redirect in my router from
/category?page=2
to
/category/page/2
here is my code
get "#{route}(:page)" => redirect {|params,request| "#{params[:name]}/#{route}/page/#{params[:page]" }
It almost works except that the last params[:page]
translates to nil
. So I get
/category/page/
Tried :page
and (:page)
- these do not work
Appreciate any help.
Upvotes: 0
Views: 47
Reputation: 56
This works like you want on rails 4.2.4
get :category, to: redirect { |params, request| "/category/#{request.params[:page]}/"}
If you need to pass the query parameters just add request.params.to_query
at the end ;)
Upvotes: 1