ruby on rails - Has_and_belongs_to_many with additional condition -


i have entities: processes , users. have many-to-many relations. user can assigned process different role: admin , owner (or both), , use boolean columns in link table.

here structure:

processes     id     name  users     id     email  processes_users     id     process_id: fk     user_id: fk     admin: boolean     owner: boolean 

is there way make 2 different has_and_belongs_to_many association these models using condition in boolean flags? want use this:

process = process.find(1) process.owners.size process.admins.size  # maybe joins process.joins(:owners).includes(:owners) 

is there way this?

use has_many :through association http://guides.rubyonrails.org/association_basics.html#choosing-between-has-many-through-and-has-and-belongs-to-many


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -