我正在创建一个应用程序来跟踪用户的就业情况以及他们在公司中的位置。我需要一些帮助来尝试路由应用程序,我已经制作了user
、company
和department
.
user
company
(用户 has_many :through => 就业)department
用户.rb
class User < ActiveRecord::Base
#associations
has_many :employments
has_many :companies, :through => :employments
has_one :department, :through => :employments
end
就业.rb
class Employment < ActiveRecord::Base
belongs_to :user
belongs_to :company
belongs_to :department
has_many :employment_histories
end
就业历史.rb
class EmploymentHistory < ActiveRecord::Base
belongs_to :employment
end
公司.rb
class Company < ActiveRecord::Base
has_many :employments
has_many :users, :through => :employments
has_many :departments
end
部门.rb
class Department < ActiveRecord::Base
belongs_to :company
end