In a Rails 3.2.11 app I have the following routes in order to redirect www to non-www:
constraints(:host => /www.foo.com/) do
root :to => redirect("http://foo.com")
match '/*path', :to => redirect {|params| "http://foo.com/#{params[:path]}"}
end
Anyway rspec throws the following warning:
DEPRECATION WARNING: redirect blocks with arity of 1 are deprecated. Your block must take 2 parameters: the environment, and a request object. (called from block (2 levels) in <top (required)> at /foo/config/routes.rb:6)
I wasn't able to find something on google so I thought to ask if anybody knows how I can get rid of this warning.
Thanks
Simply take a second parameter on the redirect block, thusly:
constraints(:host => /www.foo.com/) do
root :to => redirect("http://foo.com")
match '/*path', :to => redirect {|params,request| "http://foo.com/#{params[:path]}"}
end
You can see some documentation of this method here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With