# Email address in url generates "no route" error

**URL:** <https://www.ruby-forum.com/t/email-address-in-url-generates-no-route-error/133523>\
**Category:** Rails\
**Created:** [April 1, 2008, 10:17am UTC](https://www.ruby-forum.com/t/email-address-in-url-generates-no-route-error/133523 "2008-04-01T10:17:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [April 1, 2008, 10:17am UTC](https://www.ruby-forum.com/t/email-address-in-url-generates-no-route-error/133523/1 "2008-04-01T10:17:05Z")

</div>

Hi,

I’m trying to make unsubscribe link and currently got a route like  
this:

map.unsubscribe ‘/unsubscribe/:email’, :controller =\> ‘foo’, :action  
=\> ‘bar’

However when I put an email address in the url, it generates “no  
route” error. It’s probably caused by the dot in email addresses.

I’m using Rails 1.2.6. Any ideas how to fix it?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [April 1, 2008, 10:26am UTC](https://www.ruby-forum.com/t/email-address-in-url-generates-no-route-error/133523/2 "2008-04-01T10:26:01Z")

</div>

Hi,

Use a different char for the dot in the request. I’m assuming you’re  
generating the unsubscribe link.

Julian.

Learn Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) NEW VIDEO  
OUT 3rd APRIL  
[http://sensei.zenunit.com/](http://sensei.zenunit.com/)

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [April 1, 2008, 12:11pm UTC](https://www.ruby-forum.com/t/email-address-in-url-generates-no-route-error/133523/3 "2008-04-01T12:11:59Z")

</div>

Julian L. wrote:

> > =\> ‘bar’
> > 
> > However when I put an email address in the url, it generates “no  
> > route” error. It’s probably caused by the dot in email addresses.
> > 
> > I’m using Rails 1.2.6. Any ideas how to fix it?
> > 
> > Thanks in advance
> > 
> > >

Thanks.  
Unfortunately I can’t modify the url, at least not the email part -  
users are redirected to this unsubscribe url from another app that  
simply adds user’s email at the end of the url.

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [April 1, 2008, 12:32pm UTC](https://www.ruby-forum.com/t/email-address-in-url-generates-no-route-error/133523/4 "2008-04-01T12:32:32Z")

</div>

Szymon N. wrote:

> map.unsubscribe ‘/unsubscribe/:email’, :controller =\> ‘foo’, :action  
> =\> ‘bar’
> 
> However when I put an email address in the url, it generates “no  
> route” error. It’s probably caused by the dot in email addresses.

Try:

map.unsubscribe ‘unsubscribe/\*email’, :controller =\> ‘foo’, :action =\>  
‘bar’

instead. You’ll have the email address in params[:email][0] as the  
email part will create an array.

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [April 1, 2008, 8:42pm UTC](https://www.ruby-forum.com/t/email-address-in-url-generates-no-route-error/133523/5 "2008-04-01T20:42:33Z")

</div>

On Apr 1, 12:32 pm, Mark B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ‘bar’
> 
> instead. You’ll have the email address in params[:email][0] as the  
> email part will create an array.
> 
> –  
> Posted viahttp://www.ruby-forum.com/.

Thanks! Works perfectly
