I have join model being used with the has_many :through relationship and am doing the following....
class Job has_many :views has_many :candidates_viewd, :through => :views, :source => :candidate end
class Candidate has_many :views has_many :jobs_viewd, :through => :views, :source => :job end
class View belongs_to :candidate belongs_to :job end
def my_method user = Candidate.find(1) job = user.jobs_viewed.first user.jobs_viewed.delete(job) end
When I was using has_and_belongs_to I could use the .delete(object) method and the record in the join table would be deleted. Now has_many :through delete(object) just NULLifies the foreign key.
Is there a simple way around this or am I going to have to write custom methods to delete the specific join model record?
BTW, for all the raving I've heard about has_many :through it seems to be much more work and less freedom than has_and_belongs_to (I was using push_with_attributes and that is being deprecated)