我已经一遍又一遍地读过路线上的主题,但没有人能帮助我。所以,因为我还是Ruby的新手,我的尝试:嵌套的路线routes.rb
我希望用户拥有自己的项目。这些项目将有仓库,客户和transquans。我希望网址类似于〜/ user/1234/project/1/warehouse/...,以便授予专用权。这是我的routes.rb看起来像:
resources :users do
resources :projects do
resources :transquans
resources :warehouses
resources :clients
end
end
这是我尝试是如何从用户调用项目/ show.html.erb [已尝试了不同的变化,这一切给了我的错误消息]
<strong>Projects</strong> <%= link_to project_path(@user) %>
试图打电话给定用户给了我像
No route matches {:action=>"show", :controller=>"projects", :id=>#<User id: 64810937, name: "Tester 1", email....
也就是说消息,虽然我通过脚手架创建的项目和从未接触过“秀”的行动......
试图找出如何解决这个花费我几天,而我认为解决方案不能那么难。
编辑:我现在已经按照Ryan Bates'Screencast的前几个步骤操作,直到4:52min。然而,当敲 http://localhost:3000/users/768773789/projects
我得到然而,这我不明白另一个错误信息,说
SQLite3::SQLException: no such column: projects.user_id: SELECT "projects".* FROM "projects" WHERE ("projects".user_id = 768773789)
而schema.rb看起来像这样
create_table "clients", :force => true do |t|
t.string "name"
t.string "codename"
t.integer "demand"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "projects", :force => true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
任何仍然感激有帮助。这让我发疯。
运行命令'rake routes'来查看您当前的路线。 – taro 2012-02-08 14:07:53
我已经添加了Ruby on Rails标记,假设这是您正在使用的Web框架。 (Ruby是一种编程语言; Rails是一个使用它的Web框架。)如果这不正确,请更正标签并澄清您的问题。 – Phrogz 2012-02-08 15:04:15
你需要发布你的'rake routes' – Zepplock 2012-02-08 15:31:04