我读到mongoid中的继承,似乎所有继承的类都将保存在基类中,例如
class BaseClass
end
class ChildClass1 < BaseClass
end
class ChildClass2 < BaseClass
end
Run Code Online (Sandbox Code Playgroud)
似乎所有这些都存储在BaseClass集合中.
我实际上希望它们存储在单独的集合中,例如ChildClass1 - collection和ChildClass2 - collection.
我使用Rails 3.2.2与mongoid 2.4.6.为了保持我的集合小,我使用"store_in"语句将子对象存储在sepparate集合中的基类中.我的代码看起来像这样:
class BaseClass
include Mongoid::Document
end
class ChildClass1 < BaseClass
store_in :child_1
end
class ChildClass2 < BaseClass
store_in :child_2
end
Run Code Online (Sandbox Code Playgroud)
似乎对象随机存储在或其他子集合中.Child1类型的对象有时会存储在集合Child2中.这是我在日志中看到的令人惊讶的事情:
Started POST "/child_class_1" for 127.0.0.1 at 2012-05-22 10:22:51 -0400
Processing by ChildClass1Controller#create as HTML
MONGODB (0ms) myproject_development['child_2'].insert....
Run Code Online (Sandbox Code Playgroud)
它来自哪里?这是mongoid,rails还是mongodb中的错误?
inheritance ruby-on-rails multiple-inheritance mongodb mongoid
我正在努力将新的 Rails 6 应用程序部署到 Heroku。它在我本地运行良好。在部署过程中,我收到以下输出。
不幸的是,我对 webpack 和 Yarn 还很陌生。这似乎是 move-file 的版本/依赖关系问题,而 move-file 又似乎是 webpacker 的依赖关系。但是,我不知道如何解决这个问题。
似乎可以归结为这一行:
error move-file@2.0.0: The engine "node" is incompatible with this module. Expected version ">=10.17". Got "10.15.3"
Run Code Online (Sandbox Code Playgroud)
但是,节点不是我的节点模块之一,但似乎是已安装的二进制文件。当我跑步时
node - v
Run Code Online (Sandbox Code Playgroud)
我得到:v12.16.1
任何帮助将不胜感激。
remote: Removing bundler (2.0.2)
remote: Bundle completed (201.39s)
remote: Cleaning up the bundler cache.
remote: -----> Installing node-v10.15.3-linux-x64
remote: -----> Installing yarn-v1.16.0
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: yarn install …Run Code Online (Sandbox Code Playgroud) inheritance ×2
mongodb ×2
mongoid ×2
collections ×1
heroku ×1
node.js ×1
precompile ×1
yarnpkg ×1