尝试从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!'
以下是我正在使用的与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"
只有在尝试“摧毁”时才会发生这种情况。来自UI的现有应用程序。
非常感谢任何帮助。
答案 0 :(得分:0)
问题源于gem 'doorkeeper-mongodb'
版本> = 4.00需要gem 'doorkeeper'
。大于v3.1.0的gem 'doorkeeper'
版本具有dependent: :delete_all
关联(请参阅门卫gem文件中的doorkeeper / lib / doorkeeper / models / application_mixin.rb)。到目前为止,任何版本的Mongoid都不支持:delete_all
的级联关系,并引发NameError
例外。
我通过要求gem 'doorkeeper', '~> 3.1.0'
解决了这个问题。然而,这导致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'