alexandernst alexandernst - 4 months ago 43
Ruby Question

uninitialized constant ApplicationRecord caused by factory girl?

I get

uninitialized constant ApplicationRecord
whenever I try to run
rails db:migrate
and the backtrace seems to be pointing to a spec of
. The exact line that causes the error is

factory :test_user, class: User do

Why is that happening? How is that
isn't defined when that spec is parsed? How can I fix it?


Since Rails 5 a model file application_record.rb with class ApplicationRecord is generated. Every new model should inherit from that class instead of ActiveRecord::Base to prevent mokey patching of ActiveRecord::Base. ApplicationRecord is the new entry point for extensions.