【发布时间】:2013-02-14 17:16:08
【问题描述】:
在我的应用程序中,我的项目有票。我希望能够通过以下方式出示门票:
/projects/43/tickets
此路线有效,但会显示所有工单,而不仅仅是属于该项目的工单。我需要改变什么?
路线:
resources :projects do
resources :tickets do
collection do
get "manage"
end
end
end
型号:
class Ticket < ActiveRecord::Base
belongs_to :project
...
end
class Project < ActiveRecord::Base
has_many :tickets, :dependent => :destroy
...
end
工单通过以下方式连接到项目:
Tickets (table)
project_id
...the rest of the fields...
【问题讨论】:
标签: ruby-on-rails database ruby-on-rails-3 routes