# Nested Resources not working for me

**URL:** <https://www.ruby-forum.com/t/nested-resources-not-working-for-me/117759>\
**Category:** Rails\
**Created:** [October 19, 2007, 11:24pm UTC](https://www.ruby-forum.com/t/nested-resources-not-working-for-me/117759 "2007-10-19T23:24:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [October 19, 2007, 11:24pm UTC](https://www.ruby-forum.com/t/nested-resources-not-working-for-me/117759/1 "2007-10-19T23:24:20Z")

</div>

This code works:

map.resources :feedbacks  
map.resources :feedback\_notes, :path\_prefix =\>  
‘/feedbacks/:feedback\_id’

(this is in my config.rb file).

But this code does not:

map.resources :feedbacks do |feedback|  
feedback.resources :feedback\_notes  
end

The error is:

undefined method `new\_feedback\_note\_path’ for  
#ActionView::Base:0x21bd380c

The code in the view is:

\<%= link\_to ‘New Note’, new\_feedback\_note\_path(@feedback) %\>

I’ve been mucking around with this for half a day and can’t figure out  
what is wrong. I’m using edge rails last refreshed sometime this week.

Can anyone spot the errors of my ways?

Thanks,  
pedz

---

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [October 20, 2007, 1:21am UTC](https://www.ruby-forum.com/t/nested-resources-not-working-for-me/117759/2 "2007-10-20T01:21:49Z")

</div>

On Oct 19, 2007, at 16:24 , Perry S. wrote:

> undefined method `new\_feedback\_note\_path’ for  
> #ActionView::Base:0x21bd380c
> 
> The code in the view is:
> 
> \<%= link\_to ‘New Note’, new\_feedback\_note\_path(@feedback) %\>

This should be new\_feedback\_feedback\_note\_path(@feedback)

Michael G.  
grzm seespotcode net

---

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [October 20, 2007, 2:01am UTC](https://www.ruby-forum.com/t/nested-resources-not-working-for-me/117759/3 "2007-10-20T02:01:20Z")

</div>

Michael G. wrote:

> On Oct 19, 2007, at 16:24 , Perry S. wrote:
> 
> > undefined method `new\_feedback\_note\_path’ for  
> > #ActionView::Base:0x21bd380c
> > 
> > The code in the view is:
> > 
> > \<%= link\_to ‘New Note’, new\_feedback\_note\_path(@feedback) %\>
> 
> This should be new\_feedback\_feedback\_note\_path(@feedback)
> 
> Michael G.  
> grzm seespotcode net

Thanks. That got me past that obstacle.

Now, if I can press my luck, how should the form\_for be done?

The scaffold generates:

\<% form\_for(@feedback\_note) do |f| %\>

But, that produces:

undefined method `feedback\_notes\_path’ for  
#ActionView::Base:0x21b8efcc

---

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [October 20, 2007, 4:35pm UTC](https://www.ruby-forum.com/t/nested-resources-not-working-for-me/117759/4 "2007-10-20T16:35:40Z")

</div>

On Oct 19, 2007, at 19:01 , Perry S. wrote:

> The scaffold generates:
> 
> \<% form\_for(@feedback\_note) do |f| %\>

script/generate scaffold doesn’t produce forms that are useable for  
nested resources (though maybe there’s a flag that I’m unaware of). I  
use the more traditional

form\_for(:feedback\_note,  
:url =\> { :action =\> ‘create’, :feedback\_id =\>  
@feedback.id }) do |f|

Michael G.  
grzm seespotcode net

---

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [October 20, 2007, 5:27pm UTC](https://www.ruby-forum.com/t/nested-resources-not-working-for-me/117759/5 "2007-10-20T17:27:00Z")

</div>

have you tried \<% form\_for(@feedback, @feedback\_note) do |f| %\>

else this should work.  
\<% form\_for @feedback\_note, :url =\> feedback\_feedback\_note\_path do |f|  
%\>

> Thanks. That got me past that obstacle.
> 
> Now, if I can press my luck, how should the form\_for be done?
> 
> The scaffold generates:
> 
> \<% form\_for(@feedback\_note) do |f| %\>
> 
> But, that produces:
> 
> undefined method `feedback\_notes\_path’ for  
> #ActionView::Base:0x21b8efcc

---

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [October 20, 2007, 8:26pm UTC](https://www.ruby-forum.com/t/nested-resources-not-working-for-me/117759/6 "2007-10-20T20:26:11Z")

</div>

I think it should be:

\<% form\_for([@feedback, @feedback\_note]) do |f| %\>
