What I have (pseudo code):
Document has users (being approvers for document, either approve or not), and in this context join table should have extra column approved for each user.
user_id, document_id, approved
1 , 1 , true
2 , 1 , false
What I want is basically:
contract.approvers => returns users but with possibility to =>
contract.approvers.first.approve(:true) => and it updates JOINtable approve column to TRUE.
Answer right for this situation is optional, will appreciate advises on schema too (or maybe i should use other type of relation?).
Best How To :
HABTM has been deprecated a while ago, I think it is just a reference to has many through now.
join table name = DocumentReview
has_many :users, through: :document_reviews
has_many :documents, through: :document_reviews
I don't understand how contract fits into this, i think you are saying that a document is a contract?
I would put the approve method in a separate class
def initialize(user, document)
@document_review = DocumentReview.find_by(user: user,document: document)
#maybe more logic and such