Hi,
I have 3 models
Recommendation Job Qualification
Recommendation model has two fields as work_type and work_id(foreign key for job/qualification based on work_type as "J"/"Q")
I am facing problem in using counter_cache
I have done this in recommendation.rb
belongs_to :job , :counter_cache => true, :foreign_key => "work_id" belongs_to :qualification , :counter_cache => true, :foreign_key => "work_id"
and
in job and qualification model files
has_many :recommendations , :conditions => {:work_type => "J"}
has_many :recommendations , :conditions => {:work_type => "Q"}
Both Job and Qualification Models have a column as recommendations_count
The problem is every time an object of recommendation is created count is increased in the both the models
Please help me with this
Thanks