I have set up my blog application and have server rendering main controller properly.
I have comment controller renders a form to leave comments:
<% form_for :comment, :url => comments_path(@entry) do |f| %>
...
in my routes.rb, I have specified the resource:
map.resources :entries do |entries|
# /connments/1/add_comment
entries.resources :comments
end
so when I invoke add_comment action, it should lead to domain/stage/id/add_comment
It works properly on my local machine:
Processing StageController#add_comment (for 127.0.0.1 at 2007-08-05 12:32:01) [POST]
Session ID: 6297be32d59763815af7b57e00c01732
Parameters: {"action"=>"add_comment", "id"=>"8", "controller"=>"stage"}
Entry Columns (0.002143) SHOW FIELDS FROM entries
Entry Load (0.000554) SELECT * FROM entries WHERE (entries.`id` = 8)
Rendering within layouts/stage
Rendering stage/add_comment
Completed in 0.01506 (66 reqs/sec) | Rendering: 0.00551 (36%) | DB: 0.00270 (17%) | 200 OK http://localhost/stage/add_comment/8]
However the server generates the following error :
Processing StageController#add_comment (for 68.145.102.32 at 2007-08-05 13:27:28) [POST]
Session ID: 85a8e69db896dca20737a92996a9904d
Parameters: {"action"=>"add_comment", "id"=>"1", "controller"=>"stage"}
Rendering within layouts/stage
Rendering stage/add_comment
ActionView::TemplateError (undefined method `comments_path' for #<#<Class:0xb7426bcc>:0xb759d71c>) on line #1 of app/views/stage/add_comment.rhtml:
1: <% form_for :comment, :url => comments_path(@entry) do |f| %>
2: <p>
3: <label for="comment_name"><p>Name: (required)</p></label>
4: <%= f.text_field :name %>
any thoughts?
thanks!