New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ActiveRecord::AssociationTypeMismatch on belongs_to #1029
Comments
Hey @Quintasan! A few suggestions/ideas:
|
@gnclmorais this is happening to me and a few members of my team when we specifically change code and then run tests again. Without changing app code, you can run a spec over and over with no errors. A single code change and this error occurs until you Singular filenames, explicitly declaring factories...none of it seems to work. Any ideas? We are on rails 5.2.2 and factory_bot/factory_bot_rails 5.0.0. In test.rb, we have |
@travisofthenorth was this happening before you upgraded to 5.0.0, or is this new for you (I ask because we did make some changes to the way factory_bot_rails handles loading file definitions in 5.0.0)? |
I should also mention that some version of this has been happening for a long time and and we have a documented workaround: https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#rails-preloaders-and-rspec |
@composerinteralia it only started happening after the upgrade. Wow, I did not know about this workaround. It seems to have fixed the problem for us! Thank you so much! |
This should be fixed with Fixed with thoughtbot/factory_bot_rails#330. I will try to get a factory_bot_rails release out next week. |
@composerinteralia I'm still getting this error in development rails console (pry). I'm on rails 6 and 5.0.2 factory bot. Has a release been cut with this fix yet? |
thoughtbot/factory_bot_rails#329 went out in factory_bot_rails 5.0.2. You might be experiencing a different problem with a similar symptom. Are you able to share a sample application that demonstrates the problem? |
@composerinteralia yes happy to do so and will open a new issue thanks |
Hello,
This was asked a million times but the only working solution I found was to set
config.cache_classes = false
inconfig/environments/development.rb
which is less than optimal for development as one could guess. I am also not using Spring.What I basically do is:
Is the only way to enable the class caching or am I doing something wrong?
organization.rb
spec/factories/organizations.rb
country.rb
spec/factories/countries.rb
The text was updated successfully, but these errors were encountered: