liquidsword
liquidsword

Reputation: 83

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

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

Upvotes: 6

Views: 3075

Answers (1)

Ravi Mariya
Ravi Mariya

Reputation: 1230

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

Upvotes: 15

Related Questions