# Question:"no route found to match"

**URL:** <https://www.ruby-forum.com/t/question-no-route-found-to-match/88692>\
**Category:** Rails\
**Created:** [March 13, 2007, 4:24pm UTC](https://www.ruby-forum.com/t/question-no-route-found-to-match/88692 "2007-03-13T16:24:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zico](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/a88e4f/32.png) [@zico](https://www.ruby-forum.com/u/zico)\
**Post date:** [March 13, 2007, 4:24pm UTC](https://www.ruby-forum.com/t/question-no-route-found-to-match/88692/1 "2007-03-13T16:24:41Z")

</div>

hi.  
in my routes.rb, I have such url  
map.file ':user/:file  
it works well with following url:

1. jay/web
2. jay/web2  
but it encounters error with: jay/web2.0  
it displays : no route found to match “/post/web2.o” with  
{:method=\>:get}  
I guess it is because the char ‘.’ and rails can not translate it  
exactly.

How can I fix it ?  
thank you  
zico

---

<div class="post-metadata">

**Author:** ![zico](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/a88e4f/32.png) [@zico](https://www.ruby-forum.com/u/zico)\
**Post date:** [March 13, 2007, 9:26pm UTC](https://www.ruby-forum.com/t/question-no-route-found-to-match/88692/2 "2007-03-13T21:26:45Z")

</div>

zico wrote:

> exactly.  
> Add this to the end of your route:

, :requirements =\> { :file =\> /.\*/ }

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![zico](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/a88e4f/32.png) [@zico](https://www.ruby-forum.com/u/zico)\
**Post date:** [March 14, 2007, 10:09am UTC](https://www.ruby-forum.com/t/question-no-route-found-to-match/88692/3 "2007-03-14T10:09:59Z")

</div>

Zike Zhang wrote:

> Michael W.
> 
> thanks.it works well now.  
> but if I want to user such url: jay.zhang/web2.0.  
> I tried to change the route into:  
> 1.:user =\> ‘all’, :file =\> ‘all’ , :requirements =\> { :user =\> /._/ } , :requirements =\> { :file =\> /._/ }  
> 2.:user =\> ‘all’, :requirements =\> { :user =\> /._/ } , :file =\> ‘all’ , :requirements =\> { :file =\> /._/ }  
> but it seems that it does not take effect.  
> how to write the route in this kind of situation?  
> Thanks again.

I haven’t tested it but try something like:

:requirements =\> { :user =\> /._/, :file =\> /._/ }

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![zico](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/a88e4f/32.png) [@zico](https://www.ruby-forum.com/u/zico)\
**Post date:** [March 14, 2007, 9:52am UTC](https://www.ruby-forum.com/t/question-no-route-found-to-match/88692/4 "2007-03-14T09:52:56Z")

</div>

Michael W.

thanks.it works well now.  
but if I want to user such url: jay.zhang/web2.0.  
I tried to change the route into:  
1.:user =\> ‘all’, :file =\> ‘all’ , :requirements =\> { :user =\> /._/  
} , :requirements =\> { :file =\> /._/ }  
2.:user =\> ‘all’, :requirements =\> { :user =\> /._/ } , :file =\> ‘all’  
, :requirements =\> { :file =\> /._/ }  
but it seems that it does not take effect.  
how to write the route in this kind of situation?  
Thanks again.

Best Regards.  
Zike Zhang  
2007-03-14

* * *

From£ºMichael W.  
Date£º2007-03-14 00:32:52  
To£ºremoved\_email\_address@domain.invalid  
Cc£º  
Subject£º[Rails] Re: Question:“no route found to match”

zico wrote:

> exactly.  
> Add this to the end of your route:

, :requirements =\> { :file =\> /.\*/ }

–  
Michael W.

–~–~---------~–~----~------------~-------~–~----~  
You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en)  
-~----------~----~----~----~------~----~------~–~—

---

<div class="post-metadata">

**Author:** ![zico](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/a88e4f/32.png) [@zico](https://www.ruby-forum.com/u/zico)\
**Post date:** [March 14, 2007, 10:25am UTC](https://www.ruby-forum.com/t/question-no-route-found-to-match/88692/5 "2007-03-14T10:25:01Z")

</div>

Michael W.

yes.i have tested it like , :requirements =\> { :user =\> /._/, :file =\>  
/._/ }  
but the link redirect to the root page automatically if i wrote :  
1.jay.zh/web2.0  
2.jay.zh

Best Regards.  
Zike Zhang  
2007-03-14

* * *

From£ºMichael W.  
Date£º2007-03-14 10:09:28  
To£ºremoved\_email\_address@domain.invalid  
Cc£º  
Subject£º[Rails] Re: Question:“no route found to match”

Zike Zhang wrote:

> Michael W.
> 
> thanks.it works well now.  
> but if I want to user such url: jay.zhang/web2.0.  
> I tried to change the route into:  
> 1.:user =\> ‘all’, :file =\> ‘all’ , :requirements =\> { :user =\> /._/ } , :requirements =\> { :file =\> /._/ }  
> 2.:user =\> ‘all’, :requirements =\> { :user =\> /._/ } , :file =\> ‘all’ , :requirements =\> { :file =\> /._/ }  
> but it seems that it does not take effect.  
> how to write the route in this kind of situation?  
> Thanks again.

I haven’t tested it but try something like:

:requirements =\> { :user =\> /._/, :file =\> /._/ }

–  
Michael W.

–~–~---------~–~----~------------~-------~–~----~  
You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en)  
-~----------~----~----~----~------~----~------~–~—

---

<div class="post-metadata">

**Author:** ![zico](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/a88e4f/32.png) [@zico](https://www.ruby-forum.com/u/zico)\
**Post date:** [March 14, 2007, 11:09am UTC](https://www.ruby-forum.com/t/question-no-route-found-to-match/88692/6 "2007-03-14T11:09:11Z")

</div>

Zike Zhang wrote:

> 2007-03-14
> 
> > Michael W.  
> > I haven’t tested it but try something like:
> 
> :requirements =\> { :user =\> /._/, :file =\> /._/ }

I just tested it and it works for me with Rails 1.2.2.

routes.rb:

map.connect ‘/:user/:file’, :controller =\> “main”, :action =\> “index”,  
:requirements =\> { :user =\> /._/, :file =\> /._/ }

views/main/index.rhtml:

\<%= params[:user] -%\>  
  
\<%= params[:file] -%\>

If I input:

[http://locahost:3000/john.doe/file.ext](http://locahost:3000/john.doe/file.ext)

I see in my browser:

john.doe  
file.ext

Michael W.
