Nested Resources not working for me

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

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

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

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

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

I think it should be:

<% form_for([@feedback, @feedback_note]) do |f| %>