I am trying to figure out if my approach is proper. I have a User model and a Compensation Model. I need to allow the application admin to assign compensation to each User record. This compensation may change over time and I want to track the changes. After some research, I thought that the has_many => :through was the way to approach this using a third model called Payments to join the other two and inside that model have the user_id and compensation_id. I have the following set:
class User < ActiveRecord::Base
has_many :payments
has_many :compensations, :through => :payments
class Compensation < ActiveRecord::Base
has_many :payments
has_many :users, :through => :payments
class Payment < ActiveRecord::Base
has_many :Users
has_many :compensations
My first question is: Am I correct, that this would be the best approach knowing what I am trying to achieve? My second question is what is the simplest way to include a drop down field in the form (pooling from the compensation table) that would populate the Payment Table? Unfortunately, most web discussions I have reviewed about has_many :through centers on the models and not the view.
Any assistance would be appreciated.