Try this:
get 'e/:email' => "static#home", :format => false, :constraints => { :email => /[^\/]+/ }
Explanation:
By default, rails won't allow a .
in a parameter.
I just tried implementing an equivalent route in my own rails app, and it worked. The params hash looked like this:
{"controller"=>"pages", "action"=>"home", "email"=>"test@gmail", "format"=>"com"}
The reason it still worked for me is that by default, rails assumes anything after the .
is the format parameter (the format param is normally used, eg, to specify that you want json - eg. example.com/my_controller/index.json
).
Since you're getting the error, you must have things set up to ignore that format
parameter that is included by default.
So, you should be able to reproduce the result I got (ie, a matching route, but with the .com
part in the format
param, not the email
param) with the following:
get 'e/:email' => "static#home", :format => true
But to solve your problem, and continue to exclude format
param, but to include the .
, and everything after it, as part of your email
param, you need to pass through that last option, :constraints => { :email => /[^\/]+/ }
which basically says to allow anything but a slash in the email param.
More info here: Why do routes with a dot in a parameter fail to match?