Recognize_path discrepency


#1

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


#2

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


#3

sorry to top post… but it in your case would it be you havent set
routes up for this?

glenn


#4

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. :wink: 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