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 -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

C#.NET Oracle.ManagedDataAccess ConfigSchema.xsd -