两天前升级到莫哈韦沙漠。Rails 服务器正在运行,但是当我尝试运行 activerecord 内容时,出现错误。当我尝试运行“Account.last”或“Account.new”或其他任何东西时,它会将我踢出去并出现以下错误
objc[38551]: +[__NSPlaceholderDictionary initialize] may have been in
progress in another thread when fork() was called.
objc[38551]: +[__NSPlaceholderDictionary initialize] may have been in
progress in another thread when fork() was called. We cannot safely
call it or ignore it in the fork() child process. Crashing instead. Set
a breakpoint on objc_initializeAfterForkError to debug.
Run Code Online (Sandbox Code Playgroud)
红宝石 2.3.4
导轨 5.1.6
卸载了一些 gems 并尝试但同样的错误。这两天快死了 而且我不仅仅是升级后面临这个问题的人。
我有以下三个模型:
class Parent < ApplicationRecord
has_many :children
has_many :assets
end
class Child < ApplicationRecord
belongs_to :parent
end
class Asset < ApplicationRecord
belongs_to :parent
end
Run Code Online (Sandbox Code Playgroud)
现在我需要通过父母找出属于孩子的资产。并且“资产”具有资产类型列。所以我需要做这样的事情
Parent.first.children.each do |child|
child.parent.assets.find_by(asset_type: "first").asset_value
end
Run Code Online (Sandbox Code Playgroud)
如何避免 N+1 查询?
导轨:5.1.6
红宝石:2.3.4