0
votes

I am getting this error:

ActiveRecord::PendingMigrationError Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development

Extracted source (around line #392): 390 391 def check_pending!(connection = Base.connection) 392 raise ActiveRecord::PendingMigrationError if ActiveRecord::Migrator.needs_migration?(connection) 393 end 394 395 def load_schema_if_pending!

Rails.root: /Users/checkkdahustle/Desktop/Full Sail/25. Advanced Server-Side Languages/ASL/APP_2/Project2/ShoeDeals

Application Trace | Framework Trace | Full Trace activerecord (4.2.5) lib/active_record/migration.rb:392:in check_pending!' activerecord (4.2.5) lib/active_record/migration.rb:373:incall' actionpack (4.2.5) lib/action_dispatch/middleware/callbacks.rb:29:in block in call' activesupport (4.2.5) lib/active_support/callbacks.rb:88:in run_callbacks' activesupport (4.2.5) lib/active_support/callbacks.rb:778:in _run_call_callbacks' activesupport (4.2.5) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (4.2.5) lib/action_dispatch/middleware/callbacks.rb:27:in call' actionpack (4.2.5) lib/action_dispatch/middleware/reloader.rb:73:incall' actionpack (4.2.5) lib/action_dispatch/middleware/remote_ip.rb:78:in call' actionpack (4.2.5) lib/action_dispatch/middleware/debug_exceptions.rb:17:incall' web-console (2.2.1) lib/web_console/middleware.rb:39:in call' actionpack (4.2.5) lib/action_dispatch/middleware/show_exceptions.rb:30:incall' railties (4.2.5) lib/rails/rack/logger.rb:38:in call_app' railties (4.2.5) lib/rails/rack/logger.rb:20:inblock in call' activesupport (4.2.5) lib/active_support/tagged_logging.rb:68:in block in tagged' activesupport (4.2.5) lib/active_support/tagged_logging.rb:26:in tagged' activesupport (4.2.5) lib/active_support/tagged_logging.rb:68:in tagged' railties (4.2.5) lib/rails/rack/logger.rb:20:incall' actionpack (4.2.5) lib/action_dispatch/middleware/request_id.rb:21:in call' rack (1.6.4) lib/rack/methodoverride.rb:22:incall' rack (1.6.4) lib/rack/runtime.rb:18:in call' activesupport (4.2.5) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in call' rack (1.6.4) lib/rack/lock.rb:17:in call' actionpack (4.2.5) lib/action_dispatch/middleware/static.rb:116:incall' rack (1.6.4) lib/rack/sendfile.rb:113:in call' railties (4.2.5) lib/rails/engine.rb:518:incall' railties (4.2.5) lib/rails/application.rb:165:in call' rack (1.6.4) lib/rack/lock.rb:17:incall' rack (1.6.4) lib/rack/content_length.rb:15:in call' rack (1.6.4) lib/rack/handler/webrick.rb:88:inservice' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/webrick/httpserver.rb:138:in service' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/webrick/httpserver.rb:94:in run' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'

4
Have you tried what it's telling you to do? bin/rake db:migrate RAILS_ENV=developmentdwenzel
I just ran the line that @dwenzel suggested and this popped up: NoMethodError in Shoe#index...... im looking over my code nowCheckk
I would suggest adding this information to your question, including the full new error. It's always good to provide as much information as you can when you pose a question here in Stack Overflow; as opposed to just pasting the full error and stack trace with no context.dwenzel
ok ill do that. thanks@dwenzelCheckk

4 Answers

5
votes

Look at the very first line of the trace you posted:

ActiveRecord::PendingMigrationError Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development

That exactly is what it means:

Migrations are pending

So, you have some migrations that are yet to be run which means your schema is not up to date.

To fix it, all you have to do is run the pending migrations

bundle exec rake db:migrate

If you have already created the database and it was working before now. If this is a new app on your machine, the database doesn't exist yet. You have to first create a database and then run the migration as follow:

bundle exec rake db:create db:migrate
2
votes

bundle exec rake db:migrate this will give us solution

2
votes

rake db:migrate command will runs migrations for the current env that have not run yet. if you are on development env you don't need to specify any env . From below command you can run all pending migrations which are not run yet

For Rails version > 5

rails db:migrate

For Rails version < 5

rake db:migrate

Extra stuff

if you want to check which migrations are run and which are pending you can use bolow command

rails db:migrate:status
0
votes

If all the solutions don't work for you kill your rails server and start it again this worked for me as i ran rails db:migrate:status and found no pending migrations