How to put an email address in url on Rails
email, ruby, ruby-on-rails, url
Solution
Your constraint needs to be an actual regular expression and not a string
match "/invite_me/:email" => "application#invite_me",
:constraints => { :email => '/.+@.+\..*/' }
Should be
match "/invite_me/:email" => "application#invite_me",
:constraints => { :email => /.+@.+\..*/ }
Problem
I want to invite people who passes their email inside an url like this: ``` localhost:3000/invite_me/email@gmail.com ``` I tried this `match` but it isn't working. ``` match "/invite_me/:email" => "application#invite_me", :constraints => { :email => '/.+@.+\..*/' } ``` I'm getting the following error: ``` No route matches [GET] "/invite_me/waldyr.ar@gmail.com" ``` rake routes output: ``` root / application#index /invite_me/:email(.:format) application#invite_me {:email=>"/.+@.+\\..*/"} ```