开发者

Rails - No route matches {:action=>"new", :controller=>"comments"}

Tried everything, can't seem to locate the issue.

Error on localh开发者_开发百科ost:3000

No route matches {:action=>"new", :controller=>"comments"}

Error in server

Rendered tasks/show.html.erb within layouts/application (134.7ms)
Completed 500 Internal Server Error in 187ms

ActionView::Template::Error (No route matches {:action=>"new", :controller=>"comments"}):
    66: 
    67: <br />
    68: 
    69: <%= link_to 'New Comment', new_task_comment_path %>
    70: 
    71: 
    72: 
  app/views/tasks/show.html.erb:69:in `_app_views_tasks_show_html_erb___1205853643464254853_2489437560'
  app/controllers/tasks_controller.rb:18:in `show'

Routes.rb has my resources nested

  resources :tasks do
    resources :comments    
  end

and the relevant section of my $rake routes

$ rake routes
    task_comments GET    /tasks/:task_id/comments(.:format)          {:action=>"index", :controller=>"comments"}
                  POST   /tasks/:task_id/comments(.:format)          {:action=>"create", :controller=>"comments"}
 new_task_comment GET    /tasks/:task_id/comments/new(.:format)      {:action=>"new", :controller=>"comments"}
edit_task_comment GET    /tasks/:task_id/comments/:id/edit(.:format) {:action=>"edit", :controller=>"comments"}
     task_comment GET    /tasks/:task_id/comments/:id(.:format)      {:action=>"show", :controller=>"comments"}
                  PUT    /tasks/:task_id/comments/:id(.:format)      {:action=>"update", :controller=>"comments"}
                  DELETE /tasks/:task_id/comments/:id(.:format)      {:action=>"destroy", :controller=>"comments"}

What could I be missing here?


You aren't passing it a task_id:

new_task_comment_path(@task.id)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜