Forum: Ruby on Rails recognize_path discrepency

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
glenn (Guest)
on 2007-02-10 13:43
(Received via mailing list)
hey all - wondering if someone would relive my confusion...

given a model called say Meeting and a route as
"map.resources :meetings"

in the console:
>>r=ActionController::Routing::Routes
>>r.recognize_paths "/meetings"
=>{:action="index",:controller=>"meetings"}

all works as I expect, but if I do
>>r.recognize_paths "/meetings/1"
=>{:action="1",:controller=>"meetings"}

which is what Id expect for a map.connect, but not for a map.resources
similarly
>>r.recognize_paths "/meetings/1/new"
=>{:action="1",:controller=>"meetings",:id=>"new"}

Does recognize_path not work for map.resources, or am I doing
something  very wrong?

thanks
Glenn
Russell N. (Guest)
on 2007-02-10 16:27
(Received via mailing list)
Heh. I thought I'd pitch in this morning but I get

NoMethodError: undefined method `recognize_paths' for
#<ActionController::Routing::RouteSet:0xb787cfb4>

I tried recognize_path but it seems to be looking for more information
than
I'm giving it based on your code there.

>> r.recognize_path "/admin/users"
ActionController::RoutingError: no route found to match "/admin/users"
with
{}
        from
./script/../config/../config/../vendor/rails/actionpack/lib/action_controller/routing.rb:1299:in
`recognize_path'
        from (irb):6
>> r.recognize_path "admin/users"
ActionController::RoutingError: no route found to match "admin/users"
with
{}
        from
./script/../config/../config/../vendor/rails/actionpack/lib/action_controller/routing.rb:1299:in
`recognize_path'
        from (irb):7
>> r.recognize_path "/admin/users/"
ActionController::RoutingError: no route found to match "/admin/users/"
with
{}
        from
./script/../config/../config/../vendor/rails/actionpack/lib/action_controller/routing.rb:1299:in
`recognize_path'
        from (irb):8
>> r.recognize_path "/admin/users/new"
ActionController::RoutingError: no route found to match
"/admin/users/new"
with {}
        from
./script/../config/../config/../vendor/rails/actionpack/lib/action_controller/routing.rb:1299:in
`recognize_path'
        from (irb):9

I will say that the results you're getting aren't what I'd expect but I
can't seem to manage to make them for myself.

RSL
glenn (Guest)
on 2007-02-10 17:03
(Received via mailing list)
sorry to top post... but it in your case would it be you havent set
routes up for this?

glenn
Russell N. (Guest)
on 2007-02-10 17:53
(Received via mailing list)
That's why I used "/admin/users" as a path [something I _do_ have a path
for
in my routing] instead of what you were using. ;) If you look at that
empty
hash there, that's the problem. It's looking for a params hash most
likely
but I haven't mucked around in the source looking for documentation so I
can't tell for sure.

RSL
This topic is locked and can not be replied to.