문제

I'm trying to create a redirect for anyone that has parameters in a certain url, to the homepage. I currently have this in my routes:

match "/pr?campaign=#{'params[:campaign]'}" => redirect("/")

but it's not recognising it properly, if i put /pr?campaign=test into the url I get a page not found..

도움이 되었습니까?

해결책

I'm not sure if I'm understanding your question, maybe try this:

match '/pr'           => 'controller#action'           # responds to no additional params
match '/pr/:campaign' => 'another_controller#action'   # responds to another param.

So, /pr will be received by controller#action, but /pr/test will be received by another_controller#action and receive test as params[:campaign]

Edit (actual solution to this problem):

match '/pr' => redirect('/')
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top