camelcase 中的 Mongoid 数据库

Mongoid database in camelcase

我在 Rails 上使用 Ruby 和 Mongoid 作为数据模型。 一切正常,但我的数据库中有一个集合并存在问题。

我有一个名为的集合:"engineProfiles"

我有我的模型 class engineProfile.rb:

class EngineProfile
   include Mongoid::Document

   field :name, type: String
   field :profileId, type: String

   embedded_in :role
end

我有一个名为 role.rb 的父模型 class:

class Role
  include Mongoid::Document

  store_in collection: "role"

  field :name, type: String

  embeds_many :permissions
  embeds_many :engineProfiles
end

在每个角色集合中,里面都有一个engineProfile集合作为数组。

我的问题是数据库中集合的名称,因为如果我在 mongodb 中将集合更改为 "engine" 并在我的模型 class 中进行更改,所有工作正常。

有什么想法吗?

好的,我找到了解决方案。 当我有一个名为 "fooBar"

的集合时

模型 rb 名称需要 "foo_bar.rb"