Hi, What about to create a default route and just let the manage with the controller?
Is it too wrong? On Oct 6, 7:24 am, Dan Sadaka <[email protected]> wrote: > Hello there fellow RoR enthusiasts, > > I have been wrestling with rails 3 routes for hours trying to accomplish > the following: > > I want to use the *same url helper* (photo_url) in my views but have a > different route match made depending on the format of the parameter I > pass. Seems simple enough, right?? > > If the parameter looks like nn.nn.nnnnnn.whatever, I want the param > passed to "photos#show" to be called :site_photo_id. If the parameter > looks like an integer, I want the param passed to be :id. > > I have tried the following: > > match "/photos/:site_photo_id", :to => "photos#show", :as => "photo", > :constraints => {:site_photo_id => /\d{2}\.\d{2}\..*/} > > match "/photos/:id", :to => "photos#show", :as => "photo", > :constraints => {:id => /\d+/} > > If, in my view, I use a string like > > "/photo/#{photo.id}" > > it works. > > But, again, I want to be able to use > > photo_url(photo.id) > > Can I do that? > > TIA, > Dan > > -- > Posted viahttp://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 [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.

