简体   繁体   English

NameError(未初始化的常量Mongoid :: Relations :: Cascading :: DeleteAll):

[英]NameError (uninitialized constant Mongoid::Relations::Cascading::DeleteAll):

I've been receiving the error below when trying to delete one of my applications from http://localhost:3000/api/v1/oauth/applications . 当我尝试从http:// localhost:3000 / api / v1 / oauth / applications中删除我的一个应用程序时,我一直收到以下错误。

Started DELETE "/api/v1/oauth/applications/5930bd2aa54dd321f7248178" for ::1 
 at 2017-06-01 21:53:22 -0400
 Processing by Doorkeeper::ApplicationsController#destroy as HTML
Parameters: {"utf8"=>"✓", 
 "authenticity_token"=>"+IxdEDUYW65Hj99VUqdJ/rydjZjJE8CIFy7El5KuuZ0rf36wLE0M4qJxBUL61D1IeRW+VvgWw1o9ckXxpHBkVw==", "commit"=>"Destroy", "id"=>"5930bd2aa54dd321f7248178"}
MONGODB | localhost:27017 | playco_development.find | STARTED | {"find"=>"oauth_applications", "filter"=>{"_id"=>BSON::ObjectId('5930bd2aa54dd321f7248178')}}
MONGODB | localhost:27017 | playco_development.find | SUCCEEDED | 0.000784s
Completed 500 Internal Server Error in 9ms

NameError (uninitialized constant Mongoid::Relations::Cascading::DeleteAll):
  activesupport (4.2.8) lib/active_support/inflector/methods.rb:263:in `const_get'
  activesupport (4.2.8) lib/active_support/inflector/methods.rb:263:in `block in constantize'
  activesupport (4.2.8) lib/active_support/inflector/methods.rb:259:in `each'
  activesupport (4.2.8) lib/active_support/inflector/methods.rb:259:in `inject'
  activesupport (4.2.8) lib/active_support/inflector/methods.rb:259:in `constantize'
  activesupport (4.2.8) lib/active_support/core_ext/string/inflections.rb:66:in `constantize'
  mongoid (5.2.1) lib/mongoid/relations/metadata.rb:98:in `cascade_strategy'
  mongoid (5.2.1) lib/mongoid/relations/cascading.rb:30:in `block in cascade!'

Here are the gems I am using that are pertinent to mongoid and rails: 以下是我使用的与mongoid和rails相关的宝石:

gem 'rails', '4.2.8'
gem 'mongoid', '~> 5.2.1'
gem 'doorkeeper-mongodb', github: 'doorkeeper-gem/doorkeeper-mongodb'
gem "doorkeeper-grants_assertion", github: "doorkeeper-gem/doorkeeper-grants_assertion"

This only happens when trying to 'destroy' an existing application from the UI. 只有在尝试从UI中“销毁”现有应用程序时才会发生这种情况。

Any help would be greatly appreciated. 任何帮助将不胜感激。

The problem stemmed from gem 'doorkeeper-mongodb' requiring gem 'doorkeeper' at version >= 4.00. 问题源于gem 'doorkeeper-mongodb'需要gem 'doorkeeper'版本> = 4.00。 A version of gem 'doorkeeper' greater than v3.1.0 has a dependent: :delete_all association (see doorkeeper/lib/doorkeeper/models/application_mixin.rb within the doorkeeper gem file). 一个版本的gem 'doorkeeper'大于v3.1.0有一个dependent: :delete_all关联(参见门卫gem文件中的doorkeeper / lib / doorkeeper / models / application_mixin.rb)。 A cascading relation of :delete_all is not supported in any of version of Mongoid to date and raises the NameError exception. 到目前为止,任何版本的Mongoid都不支持:delete_all级联关系,并引发NameError异常。

I got around this by requiring gem 'doorkeeper', '~> 3.1.0' . 我通过要求gem 'doorkeeper', '~> 3.1.0'解决这个问题。 However this caused a gem dependency issue with gem 'doorkeeper-grants_assertion' which I fixed by requesting a specific commit version in my gem file as seen below: 然而,这导致了gem 'doorkeeper-grants_assertion'的gem依赖问题,我通过在我的gem文件中请求特定的提交版本来修复,如下所示:

gem 'mongoid', '~> 5.1.0'
gem 'doorkeeper-mongodb', github: 'doorkeeper-gem/doorkeeper-mongodb'
gem 'doorkeeper', '~> 3.1.0'
gem 'doorkeeper-grants_assertion', github: "doorkeeper-gem/doorkeeper-
grants_assertion", :ref => 'f4391f2f07d96845db0d9dd6889f58d4bd4d23bb'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM