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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
zico wrote:> 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.Add this to the end of your route: , :requirements => { :file => /.*/ } -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Wang 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 Wang Date:2007-03-14 00:32:52 To:rubyonrails-talk@googlegroups.com Cc: Subject:[Rails] Re: Question:"no route found to match" zico wrote:> 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.Add this to the end of your route: , :requirements => { :file => /.*/ } -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Zike Zhang wrote:> Michael Wang > > 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 Wang --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Wang 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 Wang Date:2007-03-14 10:09:28 To:rubyonrails-talk@googlegroups.com Cc: Subject:[Rails] Re: Question:"no route found to match" Zike Zhang wrote:> Michael Wang > > 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 Wang --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Zike Zhang wrote:> Michael Wang > > 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 Wang > Date:2007-03-14 10:09:28 > To:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > Cc: > Subject:[Rails] Re: Question:"no route found to match" > > > Zike Zhang wrote: >> Michael Wang >> >> 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 => /.*/ }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] -%><br/> <%= params[:file] -%><br/> If I input: http://locahost:3000/john.doe/file.ext I see in my browser: john.doe file.ext Michael Wang --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---