coriordan
unread,Jan 10, 2013, 11:29:22 AM1/10/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rubyonra...@googlegroups.com
Hi,
I have a model defined like so:
class Course < ActiveRecord::Base
has_many :attendances, :dependent => :destroy
has_many :attendees, :through => :attendances, :source => :user
...
when I attempt to delete a Course model, it results in an ActiveRecord::StaleObjectError. Reviewing the resulting SQL calls shows that the 'lock_version' column gets incremented on each dependent 'Attendance' model that is deleted. When the Course model is deleted, its lock_version no longer matches the persisted row in the database, and hence the StaleObjectError. Any help on how to handle this situation would be greatly appreciated.
regards,
Cathal.