pedz
October 19, 2007, 11:24pm
1
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
pedz
October 20, 2007, 1:21am
2
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
pedz
October 20, 2007, 2:01am
3
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
pedz
October 20, 2007, 4:35pm
4
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
pedz
October 20, 2007, 5:27pm
5
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
pedz
October 20, 2007, 8:26pm
6
I think it should be:
<% form_for([@feedback , @feedback_note ]) do |f| %>