[Rails] 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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home