NoMethodError: undefined method `needs_migration?' for ActiveRecord::Migrator:Class

activerecord, nomethoderror, ruby-on-rails

Solution

change your code to

if ActiveRecord::Base.connection.migration_context.needs_migration?
  raise 'Migrations are pending. Run `rake db:migrate` to resolve the issue.'
end

Problem

I'm getting the below error message, not sure how to resolve it. Can anyone help please? NoMethodError: undefined method `needs_migration?' for ActiveRecord::Migrator:Class Here is the config.ru code: ``` require './config/environment' if ActiveRecord::Migrator.needs_migration? raise 'Migrations are pending. Run `rake db:migrate` to resolve the issue.' end use Rack::MethodOverride use UsersController use ArtworkController run ApplicationController ```

Original source