Ruby on rails rails路由--未定义的方法

Ruby on rails rails路由--未定义的方法,ruby-on-rails,routes,Ruby On Rails,Routes,我有一个叫“新手”的模特。routes.rb文件如下所示: Myapp::Application.routes.draw do resources :newbies root to: 'static_pages#home' match '/about', to: 'static_pages#about' 控制器类似于: class NewbiesController < ApplicationController def show @new

我有一个叫“新手”的模特。routes.rb文件如下所示:

  Myapp::Application.routes.draw do
  resources :newbies

  root to: 'static_pages#home'
  match '/about',   to: 'static_pages#about'
控制器类似于:

  class NewbiesController < ApplicationController

    def show
      @newbie = Newbie.find(params[:id])
    end
    ......
  end
它总是说:

 1) Newbie pages profile page 
 Failure/Error: before { visit newbie_path(newbie)}
 NoMethodError:
   undefined method `newbie_path' for #       <RSpec::Core::ExampleGroup::Nested_2::Nested_2:0x007f97f7f33068>
 # ./spec/requests/newbie_pages_spec.rb:16:in `block (3 levels) in <top (required)>'

 2) Newbie pages profile page 
 Failure/Error: before { visit newbie_path(newbie)}
 NoMethodError:undefined method `newbie_path' for 
1)新手页面配置文件页面
失败/错误:在{访问新手路径(新手)}之前
命名错误:
#的未定义方法“newbie_path”
#./spec/requests/newbie\u pages\u spec.rb:16:in'block(3层)in'
2) 新手页面个人资料页面
失败/错误:在{访问新手路径(新手)}之前
NoMethodError:未定义的方法“newbie_path”
我认为参考资料:新手会创建像newbie_path这样的助手方法,但为什么它会说undefined方法呢

当你跑步时,谢谢你 耙道

为新手资源生成的路线与您期望的路线完全不同

newbies GET    /newbies(.:format)
{:action=>"index", :controller=>"newbies"}
         POST   /newbies(.:format)
{:action=>"create", :controller=>"newbies"}

new_newby GET    /newbies/new(.:format)
{:action=>"new", :controller=>"newbies"}

 edit_newby GET    /newbies/:id/edit(.:format)
{:action=>"edit", :controller=>"newbies"}

newby GET    /newbies/:id(.:format)
{:action=>"show", :controller=>"newbies"}
 PUT    /newbies/:id(.:format)
{:action=>"update", :controller=>"newbies"}

DELETE /newbies/:id(.:format)
{:action=>"destroy", :controller=>"newbies"}
所以你应该使用

newby_path(newbie)

你能把你所有的路线都发出去吗。通过rake routeswow,问题得以解决。看起来rails认为newbies是newby的复数,而不是newbie。。。。。newby_path很管用…谢谢你的提醒是的,刚刚也发现了…谢谢
newby_path(newbie)