How can make association with two different databases by factory_girl?
<p>Now I have two rails applications. The names are:</p>

<ul>
<li>App1</li>
<li>App2</li>
</ul>

<p>I want to do rspec test in App1. Also want to operate data in App2.</p>

<p>The model in App2:</p>

<pre><code># User
class User &lt; ActiveRecord::Base
  has_many :posts
end

# Post
class Post &lt; ActiveRecord::Base
  belongs_to :user
end
</code></pre>

<p>The factory_girl files in App1:</p>

<pre><code># spec/factories/users.rb
FactoryGirl.define do
  factory :user, :class =&gt; App2::User do
    name 'user_name'
  end
end

# spec/factories/posts.rb
FactoryGirl.define do
  factory :post, :class =&gt; App2::Post do
    association :user, factory: :user
    name 'post_name'
  end
end
</code></pre>

<p>If I create data in spec file in App1:</p>

<pre><code># spec/my_test_spec.rb
require 'rails_helper'
RSpec.describe MyTest do
  let(:app2_post) { create(:post) }
  ...
end
</code></pre>

<p>It said:</p>

<pre><code>Failure/Error: let(:app2_post) { create(:post) }

NoMethodError:
  undefined method 'user=' for #&lt;App2::Post:0x000000092933&gt;
  Did you mean? user_id=
                user_id
...
</code></pre>

<p>The <code>:user</code> is not the class in App1 but in App2. If I tried <code>association App2::User, factory: :user</code>, also got error.</p>

<p>Then how to write the association here: <code>association :user, factory: :user</code>?</p>