Tom
2008-Apr-11 20:34 UTC
[Betternestedset-talk] BetterNestedSet + ":dependent => :destroy" = BUG ?
Hi there, I use the plugin "BetterNestedSet" for a model and need to have the model option ":dependent => :destroy" at the same time. Using only one of these two things works perfectly. But using both at the same time keeps throwing an error. I have the following model structure (which is part of a slightly bigger structure): class Group < ActiveRecord::Base has_many :groupmessages, :dependent => :destroy end class Groupmessage < ActiveRecord::Base belongs_to :group acts_as_nested_set :scope => :group_id end I need to delete a group and all its "groupmessages" with it (using on the above ":dependent => :destroy"). But when I try to do it like this: Group.destroy(groupIdHere), I get the following error... ActiveRecord::RecordNotFound in GroupController#delete Couldn''t find Groupmessage with ID=61 ...but the groupmessage with the ID=61 is definitely in the database! (Btw, it''s a "child" groupmessage) Group.destroy(groupIdHere) works only if I delete "acts_as_nested_set ..." in the Groupmessage model. What can I do to make it work?? Thanks a lot for your help on this problem! Tom PS: below the end of the trace: . . . C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:80:in `transaction'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:100:in `transaction'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:104:in `destroy'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:646:in `destroy''