ユーザーの雇用と会社のどこにいるかを追跡するアプリを作成しています。アプリをルーティングするのに助けが必要です。 user
、company
、およびの足場を作成しdepartment
ました。
user
company
(ユーザー has_many :through => 雇用)department
user.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
company.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