想象一下。我在 URLhttp://localhost:3000/companies/3
上,在这个视图上,我想要一个employees
按钮来http://localhost:3000/companies/3/employees
在我的路线文件中,我有
namespace :companies, :only => [:index, :show, :new, :edit, :destroy], :path => "/:companies" do
resources :employees, :only => [:index, :edit, :new, :show] do
end
end
我知道我需要链接到“员工”的索引操作,但我不知道在我的公司“显示”页面上添加什么。现在看来
%a{title: "company1", href: "#"} Employees
(我正在使用haml,但请随时在erb中发布您的答案)
在 rake 路线中,我得到
companies_employees GET /:companies/employees(.:format) companies/employees#index
...但我想要公司/company_id/employees
谢谢!