Hello all, I have the following model, Purchase, on my Rails app:
class Purchase < ActiveRecord::Base
[...]
belongs_to :payment, :validate => true
belongs_to :day, :foreign_key => :day_day, :primary_key => :day,
:counter_cache => true
[...]
end
And I have the Day model:
class Day < ActiveRecord::Base
[...]
has_many :purchases, :foreign_key => :day_day, :primary_key => :day
[...]
end
I'd like to create an association between the day and the payments occurred during that day through the Purchase model. Is it possible?
Thanks a lot!