# Resource routing methods -- what am I missing?

**URL:** <https://www.ruby-forum.com/t/resource-routing-methods-what-am-i-missing/121935>\
**Category:** Rails\
**Created:** [December 3, 2007, 2:56am UTC](https://www.ruby-forum.com/t/resource-routing-methods-what-am-i-missing/121935 "2007-12-03T02:56:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![enchanter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@enchanter](https://www.ruby-forum.com/u/enchanter)\
**Post date:** [December 3, 2007, 2:56am UTC](https://www.ruby-forum.com/t/resource-routing-methods-what-am-i-missing/121935/1 "2007-12-03T02:56:48Z")

</div>

Alright, I’ve been doing map.resources routing for a while now, so  
whatever I’m missing must be something stupid and obvious… Anyone  
care to help me out?

– routes.rb:

# …

map.resources :algorithms, :collection =\> { :search =\> :post } do  
|algorithm|  
algorithm.resources :snippets  
end

# …

– snippets\_controller.rb  
class SnippetsController \< ApplicationController  
def show  
# …  
end  
end

– algorithms\_controller.rb  
class AlgorithmsController \< ApplicationController

# …

```
redirect_to algorithm_snippet_url(@algorithm, @snippet) # <- no such

```

method  
redirect\_to snippet\_url(@algorithm, @snippet) # \<- no such method

# …

end

---

<div class="post-metadata">

**Author:** ![enchanter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@enchanter](https://www.ruby-forum.com/u/enchanter)\
**Post date:** [December 3, 2007, 3:07am UTC](https://www.ruby-forum.com/t/resource-routing-methods-what-am-i-missing/121935/2 "2007-12-03T03:07:44Z")

</div>

> Alright, I’ve been doing map.resources routing for a while now, so  
> whatever I’m missing must be something stupid and obvious… Anyone  
> care to help me out?

Call rake routes to see all the routes you have declared. That usually  
makes it obvious what the problem is.

---

<div class="post-metadata">

**Author:** ![enchanter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@enchanter](https://www.ruby-forum.com/u/enchanter)\
**Post date:** [December 3, 2007, 3:09am UTC](https://www.ruby-forum.com/t/resource-routing-methods-what-am-i-missing/121935/3 "2007-12-03T03:09:16Z")

</div>

DHH wrote:

> > Alright, I’ve been doing map.resources routing for a while now, so  
> > whatever I’m missing must be something stupid and obvious… Anyone  
> > care to help me out?
> 
> Call rake routes to see all the routes you have declared. That usually  
> makes it obvious what the problem is.

Right here, in white on black:

algorithm\_snippet  
GET  
/algorithms/:algorithm\_id/snippets/:id  
{:controller=\>“snippets”, :action=\>“show”}

so, given that … it’s most definitely  
algorithm\_snippet\_url(@algorithm, @snippet) … right?

---

<div class="post-metadata">

**Author:** ![enchanter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@enchanter](https://www.ruby-forum.com/u/enchanter)\
**Post date:** [December 4, 2007, 5:57pm UTC](https://www.ruby-forum.com/t/resource-routing-methods-what-am-i-missing/121935/4 "2007-12-04T17:57:02Z")

</div>

> Right here, in white on black:
> 
> algorithm\_snippet  
> GET  
> /algorithms/:algorithm\_id/snippets/:id  
> {:controller=\>“snippets”, :action=\>“show”}
> 
> so, given that … it’s most definitely  
> algorithm\_snippet\_url(@algorithm, @snippet) … right?

Yes. Are you running on latest edge? I can’t remember how this worked  
on 1.2.x.

---

<div class="post-metadata">

**Author:** ![enchanter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@enchanter](https://www.ruby-forum.com/u/enchanter)\
**Post date:** [December 4, 2007, 7:46pm UTC](https://www.ruby-forum.com/t/resource-routing-methods-what-am-i-missing/121935/5 "2007-12-04T19:46:03Z")

</div>

DHH wrote:

> > Right here, in white on black:
> > 
> > algorithm\_snippet  
> > GET  
> > /algorithms/:algorithm\_id/snippets/:id  
> > {:controller=\>“snippets”, :action=\>“show”}
> > 
> > so, given that … it’s most definitely  
> > algorithm\_snippet\_url(@algorithm, @snippet) … right?
> 
> Yes. Are you running on latest edge? I can’t remember how this worked  
> on 1.2.x.

Bah, I just figured it out and it was a stupid mistake. My code was  
outside a method scope and was therefore being evaluated at the static  
class level.
