路由REST重定向在Rails 4.0中无法正常工作

时间:2014-02-18 09:17:52

标签: ruby-on-rails ruby-on-rails-4 routes

我已为我的应用添加了新资源。

  resources :posts do
    resources :comments
  end

相同的Rake路由也显示正确的重定向路径。

rake routes CONTROLLER=posts

   Prefix Verb   URI Pattern               Controller#Action
    posts GET    /posts(.:format)          posts#index
          POST   /posts(.:format)          posts#create
 new_post GET    /posts/new(.:format)      posts#new
edit_post GET    /posts/:id/edit(.:format) posts#edit
     post GET    /posts/:id(.:format)      posts#show
          PATCH  /posts/:id(.:format)      posts#update
          PUT    /posts/:id(.:format)      posts#update
          DELETE /posts/:id(.:format)      posts#destroy

但是当我使用以下代码行时:

<%= link_to 'Get Complete Blog List', posts_path %>

投掷错误:

undefined method `posts_path' for #<#<Class:0xb464058c>:0xb4e8a274>

0 个答案:

没有答案