Drayton Miles
2012-Aug-10 00:59 UTC
Rails routing - redirection with block AND status code
Well, I''ve been hitting my head against a brick wall with this one -
any
help much appreciated!
I''m redirecting old urls in my routes.rb file and for the most part
that''s working well, e.g.:
match ''/pages/holiday-specials/'', :to => redirect(
"/accommodation",
:status => 301 )
However, I need a special catch-all rule that needs to do some regex
checking, so I have a final rule which contains a block. The code below
works well EXCEPT I can''t get it to pass the status, no matter what
combination I try.
match ''/*:path'', :to => redirect( lambda { |params|
"/operator/#{/[^\d](\d+)([^\d]|$)/.match(params[:path])[1]}" },
:status
=> 301)
Any ideas? How do you perform a redirection with a block AND status
code?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Drayton Miles
2012-Aug-10 04:27 UTC
Re: Rails routing - redirection with block AND status code
Never mind. Worked it out. Actually I had another rule that was being matched first and it wasn''t doing a 301 redirect. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.