Ruby Forum Ruby on Rails > Email address in url generates "no route" error

Posted by Szymon Nowak (szimek)
on 01.04.2008 10:17
(Received via mailing list)
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
Posted by Julian Leviston (Guest)
on 01.04.2008 10:26
(Received via mailing list)
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/
Posted by Szymon Nowak (szimek)
on 01.04.2008 12:11
(Received via mailing list)
Julian Leviston 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.
Posted by Mark Bush (bush)
on 01.04.2008 12:32
Szymon Nowak 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.
Posted by Szymon Nowak (szimek)
on 01.04.2008 20:42
(Received via mailing list)
On Apr 1, 12:32 pm, Mark Bush <rails-mailing-l...@andreas-s.net>
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