私はこのモデルを持っています:
class Application < ActiveRecord::Base
has_many :admin_user_applications, dependent: :destroy
has_many :admin_users, through: :admin_user_applications, :source => :user, validate: :false
end
class User < ActiveRecord::Base
has_many :admin_user_applications, dependent: :destroy
has_many :administrable_applications, through: :admin_user_applications, :source => :application
end
class UserApplication < ActiveRecord::Base
belongs_to :user
belongs_to :application
end
アプリケーションファクトリーを定義しました:
FactoryGirl.define do
factory :application, :class => Application do
sequence(:name) {|n| "application-#{n}" }
association :owner, :factory => :user
end
end
しかし、私がこれを行うと:
app_3 = FactoryGirl.create(:application, admin_users: [@user])
puts @user.admin_user_applications.inspect # =>[]
それは私を返します[]
私は何を間違っていますか?