【发布时间】:2023-03-25 19:15:01
【问题描述】:
在轨道上使用 mongoid
gem 'rails', '~> 5.1.4'
gem 'mongoid', '~> 6.1.0'
Mongodb version: 3.4.10
我的 mongoid.yml
development:
clients:
default:
database: xxxx_development
hosts:
- xxx.xx.147.208:2200
user: 'root'
password: "xxxxxxxx"
auth_source: admin
用户 root 具有 root 角色。用户/密码可以使用 MongoBooster 和 mongo cli,我的意思是可以使用 db.xxx.find({})。
但在我的 rails 应用程序中,它只是抛出
MONGODB | Topology type 'unknown' initializing.
MONGODB | Server xxx.xx.147.208:2200 initializing.
MONGODB | Topology type 'unknown' changed to type 'single'.
MONGODB | Server description for xxx.xx.147.208:2200 changed from 'unknown' to 'standalone'.
MONGODB | There was a change in the members of the 'single' topology.
MONGODB | xxx.xx.147.208:2200 | xxxx_development.count | STARTED | {"count"=>"news", "query"=>{}}
MONGODB | 116.62.147.208:2200 | xxxx_development.count | FAILED | not authorized on xxxx_development to execute command { count: "news", query: {} } (13) | 0.153356s
Completed 500 Internal Server Error in 364ms
我尝试了许多不同的配置,但无法使 mongoid 授权工作。 任何帮助将不胜感激。
【问题讨论】:
标签: ruby-on-rails passwords mongoid authorize