Rails 3路由到错误的控制器

Kir*_*iki 4 ruby-on-rails rails-routing ruby-on-rails-3

我想创建一个新动作,我称之为"showemployees".这就是我已经做过的事情:

- >在控制器中:

def showemployees
end
Run Code Online (Sandbox Code Playgroud)

- >创建app/views/employees/showemployees.html.erb

- >在config/routes中

match "/employees/showemployees" => "employees#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
Run Code Online (Sandbox Code Playgroud)

我需要改变什么才能让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
Run Code Online (Sandbox Code Playgroud)

Ana*_*oly 5

尝试通过Rails-way行走,如果你想获得收藏,请使用该集合

resources :employees do
  collection do
    get :showemployees
  end
end
Run Code Online (Sandbox Code Playgroud)