ruby-on-rails – Rails 3路由到错误的控制器
发布时间:2020-12-17 02:52:56 所属栏目:百科 来源:网络整理
导读:我想创建一个新动作,我称之为“showemployees”.这就是我已经做过的事情: – 在控制器中: def showemployeesend – 创建app / views / employees / showemployees.html.erb – 在配置/路由中 匹配“/ employees / showemployees”= “员工#showemployees”
我想创建一个新动作,我称之为“showemployees”.这就是我已经做过的事情:
– >在控制器中: def showemployees end – >创建app / views / employees / showemployees.html.erb – >在配置/路由中 匹配“/ employees / showemployees”=> “员工#showemployees” 我认为这足以通过localhost:3000 / employees / showemployees打开showemployees.html.erb,但似乎Rails仍然通过show action(来自资源:employees)进行路由,并且不接受showemployees-action,因为它告诉我 ActiveRecord::RecordNotFound in EmployeesController#show Couldn't find Employee with ID=showemployees 我需要改变什么才能让Rails接受showemployees-action? 我的路线的源代码: System::Application.routes.draw do match "/employees/showemployees" => "employees#showemployees" #für showemployees.html.erb root :to => "employees#index" resources :course_to_dos resources :current_qualifications resources :expected_qualifications resources :skills resources :employees resources :positions resources :admin end 解决方法
尝试通过Rails-way行走,如果你想获得收藏,请使用该集合
resources :employees do collection do get :showemployees end end (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |