Question:"no route found to match"

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

zico wrote:

exactly.
Add this to the end of your route:

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


Michael W.

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.

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£º[email protected]
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 [email protected]
To unsubscribe from this group, send email to
[email protected]domain.invalid
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~–~—

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£º[email protected]
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~–~—

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

I see in my browser:

john.doe
file.ext

Michael W.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs