I have 3 tables, A, B and C where A habtm C through B and vice versa
(C habtm A).
I also have a Users table which habtm B
In other words, B can be filtered by the current user, and requires a
userId to be valid (only a logged in user can add a new C record).
This is a testing application, where you have questions, answers and
users. In this application, the answers are all cardinal values, so I
want to be able to go backwards from answers to questions, thus the
two-way habtm between A and C (A is Questions, C is answer choices,
and every question has many answer choices, and every answer choice
has many questions).
When user creates a new entry in C, for a given instance of A, a, I
can do one of two things -
a) create a new C, insert it into a's C collection, and in B's
beforeCreate, manually set the UserId
This requires the model to access a controller method to get the
current user - is this bad Rails form?
b) use the user object to create a B instance, b, and set b's C to c,
and b's A to a manually.
Which is better?
Or, is there a built in ActiveRecord way to manage 3 way joins?