Created
July 8, 2011 21:13
-
-
Save cmaujean/1072833 to your computer and use it in GitHub Desktop.
nested destroy problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bar < ActiveRecord::Base | |
acts_as_nested_set :dependent => :destroy | |
belongs_to :foo | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> Foo.destroy_all | |
ActiveRecord::RecordNotFound: Couldn't find Bar with ID=2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo < ActiveRecord::Base | |
has_many :bars, :dependent => :destroy | |
has_one :root, :class_name => 'Bar', :conditions => "parent_id is null" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment