我运行测试,控制器spec/controllers/educations_controller_spec.rb
上,使用RSpec。的ActionController :: UrlGenerationError:没有路由匹配{:动作=> “指数”:控制器=> “教育”}
即使在我最基础的测试获得:index
我收到错误:
ActionController::UrlGenerationError: No route matches {:action=>"index", :controller=>"educations"}
我所看到的关于显示/编辑/更新帖子在需要的ID,但我不认为一个id应该是索引操作所必需的。
在投机/控制器/ educations_controller_spec.rb:
require 'rails_helper'
RSpec.describe EducationsController, type: :controller do
describe 'GET #index' do
it "renders the :index template" do
get :index
expect(response).to render_template :index
end
end
end
我的路线文件中包含该索引操作:
resources :applications, only: [:index, :new, :show, :create, :edit, :update] do
resources :educations, only: [:index, :new, :create, :edit, :update]
resources :montessori_trainings, only: [:index, :new, :create, :edit, :update]
resources :work_experiences, only: [:index, :new, :create, :edit, :update]
resources :references, only: [:index, :new, :create, :edit, :update]
resources :documents, only: [:index, :new, :create, :edit, :update]
end
你认为它是与被嵌套在教育路线应用程序路线?
我使用的设计。那里会有冲突吗?
感谢您的任何和所有的建议!
是已经制定的控制器,并列出了一个索引操作? –
如果您运行'rake routes',会出现'GET/educations'? – tegon