0
我正在創建一個跟蹤用戶就業情況和他們在公司中的應用程序。我需要一些幫助來嘗試路由應用程序,我製作了腳手架user
,company
和department
。我將如何路由此層次結構
user
company
(用戶的has_many:通過=>外水)department
user.rb
class User < ActiveRecord::Base
#associations
has_many :employments
has_many :companies, :through => :employments
has_one :department, :through => :employments
end
employment.rb
class Employment < ActiveRecord::Base
belongs_to :user
belongs_to :company
belongs_to :department
has_many :employment_histories
end
employment_history.rb
class EmploymentHistory < ActiveRecord::Base
belongs_to :employment
end
company.rb
class Company < ActiveRecord::Base
has_many :employments
has_many :users, :through => :employments
has_many :departments
end
department.rb
class Department < ActiveRecord::Base
belongs_to :company
end
用你的方法,招聘/解聘會怎麼樣? – Jaba 2012-07-11 13:31:03
那麼,你可以爲每個僱傭人員創造一個新的就業機會,並且沒有結束日期,然後開除將會給就業一個結束日期,從而表明它已經結束。 – AJcodez 2012-07-11 16:41:48