【发布时间】:2018-09-20 20:02:06
【问题描述】:
我在一个应用中有两个数据库
- Postgres
- MongoDB
除了一个型号,所有型号都在Postgres
型号名称Message 在MongoDB 中如下
-
message.rb- MongoDBclass Message include Mongoid::Document field :content, type: String field :user_id, type: Integer end -
user.rb- Postgresclass User < ApplicationRecord end
现在我想将user 模型与message 模型相关联,以执行eagerloading。
如果我写belongs_to :user,然后执行Message.last.user,则会出现以下错误
NoMethodError (undefined method `_association' for []:Array)
有没有办法解决这个问题?
【问题讨论】:
标签: ruby-on-rails mongodb postgresql ruby-on-rails-5.1