I have a situation where it seems rails should delete dependent records but does not:
class Order < ActiveRecord::Base has_many :line_items, :dependent => :destroy end
class LineItem < ActiveRecord::Base belongs_to :order end
o=Order.new li=LineItem.new o.line_items<<li o.save! Order.delete(o.id)
This deletes the order but not the line item. I did a little debugging and see that rails adds the code (associations.rb):
case reflection.options[:dependent] when :destroy, true module_eval "before_destroy '#{reflection.name}.each { | o> o.destroy }'"
but if I add a before_destroy to Order, it is never called. There was another post on this but I didn't really see an explanation for this. More of a workaround.
Rails is great and all, but running into what seems to be very simple cases that don't work and having to step thru very cryptic rails code isn't much fun.
I guess I'll add cascade/delete to the database tables....