habtm, , , has_many: through. . , .
, "" . , . .
create_table :project_services do |t|
t.references :project
t.references :service_type
t.string :status
end
class ProjectService < ActiveRecord::Base
belongs_to :project
belongs_to :service
end
class Project < ActiveRecord::Base
has_many :project_services
has_many :accepted_services, :through => :project_services,
:conditions => { :status => 'accepted' }
has_many :proposed_services, :through => :proposed_services,
:conditions => { :status => 'proposed' }
end
class Service < ActiveRecord::Base
has_many :project_services
has_many :accepted_projects, :through => :project_services,
:conditions => { :status => 'accepted' }
has_many :proposed_projects, :through => :proposed_services,
:conditions => { :status => 'proposed' }
end