thoughtbot/factory_girl — pull request #641 by dwhenry (2014-04-03 22:47:48+00:00)
Title: Allow setting of class on association

Given the model classes

```
class User < ActiveRecord::Base
end

class GenericEngine::User < ActiveRecord::Base
table_name = 'user'
end

class Post < ActiveRecord::Base
belongs_to :user, class_name: GenericEngine::User
end
```

This pull requests adds the following syntax:
```
FactoryGirl.define do
factory :user

factory :post do
user class: User::User
end
end
```

This allows support for sharing database tables across engine models. Specifically to combat the occurrence of the error:

```
ActiveRecord::AssociationTypeMismatch:
GenericEngine::User(#70355900521280) expected, got User(#70355900924220)
```

when you do:

```
create(:post)
```
or
```
user = create(:user)
create(:post, user: user)
```