【发布时间】:2012-05-07 14:23:25
【问题描述】:
在将路由从 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 - 我希望它成为动作。
我该怎么做?
【问题讨论】:
-
routes.rb中还有什么else?在/clients/getAnimals匹配之前 是否有与URL 匹配的内容?像客户端资源,还是类似的?
标签: ruby-on-rails ruby-on-rails-3