Ruby on rails 未定义的方法`类别文件`路径';在轨道上。我的路线有评论而不是文档

Ruby on rails 未定义的方法`类别文件`路径';在轨道上。我的路线有评论而不是文档,ruby-on-rails,routes,nested-forms,Ruby On Rails,Routes,Nested Forms,我尝试对嵌套表单执行此操作,当我加载表单(/categories/show.html.haml)时,会出现以下错误: NoMethodError in Categories#show Showing /home/cederic/rails/mordus/app/views/categories/show.html.haml where line #6 raised: undefined method `category_documentations_path' for #<#<C

我尝试对嵌套表单执行此操作,当我加载表单(/categories/show.html.haml)时,会出现以下错误:

NoMethodError in Categories#show

Showing /home/cederic/rails/mordus/app/views/categories/show.html.haml where line #6 raised:

undefined method `category_documentations_path' for #<#<Class:0x00007fead8742870>:0x00007fead8881038>
Did you mean?  category_comments_path
“rails routes”命令的输出:


这些资源路由与“rails路由”的输出不匹配-自从运行“rails路由”以来,您是否更改了
routes.rb
文件?如果您的
routes.rb
看起来像您上面说的那样,“rails routes”应该返回以下内容(使用“文档”而不是“注释”):


找到了。这是一只奇怪的虫子。。不知道它是否来自我的文本编辑器或其他什么,但我复制routes.rb的内容,删除它,创建一个新的routes.rb文件并粘贴内容,现在它可以工作了

您忘记保存routes.rb文件了吗?保存了3次您做了一些非常错误的事情,因为routes文件没有给出输出。检查slop错误(错误的文件、错误的路径、错误的git分支等)。我怀疑是我的文本编辑器打开了错误的文件。。。我曾经删除它,然后再做一次,tadam:它可以工作:D谢谢:)这是我的实际路线,我确认它从来没有评论路线。一切都是最新的,我在创建问题时仔细检查了它。
Rails.application.routes.draw do
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html

    resources :categories do
        resources :documentations
    end

    get 'pages/accueil'

    root 'pages#accueil'
end
refix Verb   URI Pattern                                          Controller#Action
    category_comments GET    /categories/:category_id/comments(.:format)          comments#index
                      POST   /categories/:category_id/comments(.:format)          comments#create
 new_category_comment GET    /categories/:category_id/comments/new(.:format)      comments#new
edit_category_comment GET    /categories/:category_id/comments/:id/edit(.:format) comments#edit
     category_comment GET    /categories/:category_id/comments/:id(.:format)      comments#show
                      PATCH  /categories/:category_id/comments/:id(.:format)      comments#update
                      PUT    /categories/:category_id/comments/:id(.:format)      comments#update
                      DELETE /categories/:category_id/comments/:id(.:format)      comments#destroy
           categories GET    /categories(.:format)                                categories#index
                      POST   /categories(.:format)                                categories#create
         new_category GET    /categories/new(.:format)                            categories#new
        edit_category GET    /categories/:id/edit(.:format)                       categories#edit
             category GET    /categories/:id(.:format)                            categories#show
                      PATCH  /categories/:id(.:format)                            categories#update
                      PUT    /categories/:id(.:format)                            categories#update
                      DELETE /categories/:id(.:format)                            categories#destroy
           pages_home GET    /pages/home(.:format)                                pages#home
                 root GET    /                                                    pages#home
    category_documentations GET /categories/:category_id/documentations(.:format) comments#index
    category_documentations POST /categories/:category_id/documentations(.:format) comments#create
    ...