在将路由从 Rails 2 转换为 Rails 3 时,我需要一些帮助。
在app/views/layouts/application.html.erb
中,我有:
<%= link_to "Reports", reports_path %><br>
有一个ReportsController
,在app/views/reports/index.html.erb
,我有这个:
<%= link_to "Clients With Animals", :action => "getAnimals", :controller => "clients" %>
然后,在 config/routes.rb 中,我有这个(Rails 3)
match '/reports' => "reports#index"
match '/clients/getAnimals', to: "clients#getAnimals"
单击报告页面上的“getAnimals”链接时出现此错误:
ActiveRecord::RecordNotFound in ClientsController#show
Couldn't find Client with id=getAnimals
我不希望“getAnimals”成为 ID - 我希望它成为动作。
我怎么做?