Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2630

cascade_strategy is null with habtm relation

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.15
    • Affects Version/s: None
    • Component/s: None

      So, when I destroy the model on the one side, an exception is raised:

          NoMethodError: undefined method `new' for nil:NilClass
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/bundler/gems/mongoid-b917c3a59e62/lib/mongoid/relations/cascading.rb:32:in `block in cascade!'
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/bundler/gems/mongoid-b917c3a59e62/lib/mongoid/relations/cascading.rb:28:in `each'
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/bundler/gems/mongoid-b917c3a59e62/lib/mongoid/relations/cascading.rb:28:in `cascade!'
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/bundler/gems/mongoid-b917c3a59e62/lib/mongoid/persistence/deletion.rb:22:in `prepare'
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/bundler/gems/mongoid-b917c3a59e62/lib/mongoid/persistence/operations/remove.rb:26:in `persist'
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/bundler/gems/mongoid-b917c3a59e62/lib/mongoid/persistence.rb:62:in `remove'
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/bundler/gems/mongoid-b917c3a59e62/lib/mongoid/persistence.rb:34:in `block in destroy'
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:403:in `_run__2019556365422146964__destroy__2408782356975295821__callbacks'
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_destroy_callbacks'
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/bundler/gems/mongoid-b917c3a59e62/lib/mongoid/callbacks.rb:114:in `run_callbacks'
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/bundler/gems/mongoid-b917c3a59e62/lib/mongoid/persistence.rb:33:in `destroy'
              from (irb):23
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
              from /Users/ulitiy/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
              from script/rails:6:in `require'
      

      Explicit dependent: :nullify solves the problem.

      On this side I have 3rd level deep inherited mongoid document model, on that side - simple mongoid document model.

            Assignee:
            durran Durran Jordan
            Reporter:
            ulitiy ulitiy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: