uninitialized constant ApplicationRecord

If you are getting this after moving from Rails 5 to Rails 6, ensure you change

config.load_defaults 5.2

for

config.load_defaults 6.0

in your config/application.rb file.


Referring to infused's answer from https://stackoverflow.com/a/41388844/5598043

Create a new file called app/models/application_record.rb with the following content:

class ApplicationRecord < ActiveRecord::Base
  self.abstract_class = true
end

It appears you're using the Rails 5 tutorial, but working with Rails 4. In Rails 5 all models inherit from ApplicationRecord, while Rails 4 from ActiveRecord::Base

Immediate fix:

class User < ActiveRecord::Base
...
end

Long term fix, switch to Rails 5 and learn with Rails 5