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

undefined method `cascade_strategy' for nil:NilClass (NoMethodError)

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

      My models are essentially:

      Unable to find source-code formatter for language: `ruby. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      class Post
      end
      
      class Topic < Post
        has_many :replies, dependent: :destroy
      end
      
      class Reply < Post
        belongs_to :topic
      end
      

      `

      Now, whenever I try to delete/destroy a Reply at any point, I get the following:

      Unable to find source-code formatter for language: `. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/bundler/gems/mongoid-939484f3bdcc/lib/mongoid/relations/cascading.rb:31:in `block in cascade!': undefined method `cascade_strategy' for nil:NilClass (NoMethodError)
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/bundler/gems/mongoid-939484f3bdcc/lib/mongoid/relations/cascading.rb:28:in `each'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/bundler/gems/mongoid-939484f3bdcc/lib/mongoid/relations/cascading.rb:28:in `cascade!'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/bundler/gems/mongoid-939484f3bdcc/lib/mongoid/persistence/deletion.rb:22:in `prepare'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/bundler/gems/mongoid-939484f3bdcc/lib/mongoid/persistence/operations/remove.rb:26:in `persist'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/bundler/gems/mongoid-939484f3bdcc/lib/mongoid/persistence.rb:61:in `remove'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/bundler/gems/mongoid-939484f3bdcc/lib/mongoid/persistence.rb:33:in `block in destroy'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:414:in `_run__917134494721936567__destroy__511223023679296584__callbacks'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:405:in `__run_callback'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:385:in `_run_destroy_callbacks'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:81:in `run_callbacks'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/bundler/gems/mongoid-939484f3bdcc/lib/mongoid/callbacks.rb:95:in `run_callbacks'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/bundler/gems/mongoid-939484f3bdcc/lib/mongoid/persistence.rb:32:in `destroy'
      	from /Users/eleo/Projects/yellowcake/models/post.rb:115:in `user_delete'
      	from /Users/eleo/Projects/yellowcake/test/models/post_behavior.rb:133:in `block (3 levels) in behaves_like_post'
      	from /Users/eleo/Projects/yellowcake/test/models/post_behavior.rb:144:in `call'
      	from /Users/eleo/Projects/yellowcake/test/models/post_behavior.rb:144:in `block (3 levels) in behaves_like_post'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/situation.rb:42:in `instance_eval'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/situation.rb:42:in `setup'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/runnable.rb:49:in `run'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/context.rb:101:in `block in local_run'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/context.rb:101:in `each'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/context.rb:101:in `local_run'
      	from /Users/eleo/Projects/yellowcake/test/test_helpers.rb:5:in `run'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/context.rb:135:in `block in run_sub_contexts'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/context.rb:135:in `each'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/context.rb:135:in `run_sub_contexts'
      	from /Users/eleo/Projects/yellowcake/test/test_helpers.rb:7:in `run'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/context.rb:135:in `block in run_sub_contexts'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/context.rb:135:in `each'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/context.rb:135:in `run_sub_contexts'
      	from /Users/eleo/Projects/yellowcake/test/test_helpers.rb:7:in `run'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/context.rb:135:in `block in run_sub_contexts'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/context.rb:135:in `each'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/context.rb:135:in `run_sub_contexts'
      	from /Users/eleo/Projects/yellowcake/test/test_helpers.rb:7:in `run'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot.rb:39:in `block (2 levels) in run'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot.rb:39:in `each'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot.rb:39:in `block in run'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot/reporter.rb:45:in `summarize'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot.rb:38:in `run'
      	from /Users/eleo/.rvm/gems/ruby-1.9.3-p194@yellowcake/gems/riot-0.12.5/lib/riot.rb:129:in `block in <module:Riot>'
      

      `

      If I get rid of the dependent option on the association, the problem is alleviated. Trying other options such as :nullify causes the same problem.

      This is with 3.0.0rc as well as HEAD, but worked in prior versions.

      Perhaps this is related to STI?

            Assignee:
            Unassigned Unassigned
            Reporter:
            ghost Deleted user
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: