0

我的帐户有一个特定的数据库(称为 account_base):

class Account < ActiveRecord::Base

  establish_connection :account_base
  
  ...
end

我有来自 app rails 数据库的用户:

class User < ActiveRecord::Base
  belongs_to :account
end

当我尝试User.first.account这项工作时。

现在我想让所有用户拥有 account => state == Account::STATE_ACTIVED,我尝试:

User.includes(:account).where('accounts.state' => Account::STATE_ACTIVED)

但我有这个错误:

Mysql2::Error: 表 'RAILS_DATABASE_NAME.accounts' 不存在

我尝试where('account_base.accounts.state'指定 bd,但不起作用

任何想法 ?

4

0 回答 0