我试图运行http://localhost:3000/users/sign_up,但它给了我这个错误:
ActiveRecord::PendingMigrationError
Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development
Rails.root: c:/xampp/htdocs/pinteresting
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:in `call'
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:in `call'
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:in `call'
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:in `call'
railties (4.2.5) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.5) lib/rails/rack/logger.rb:20:in `block 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:in `call'
actionpack (4.2.5) lib/action_dispatch/middleware/request_id.rb:21:in `call'
这让我很头疼。我是rails的新手,我确保通过devise gem正确设置了所有内容。那我该怎么办?有什么帮助吗?
我运行bin/rake db:migrate RAILS_ENV=development
但它说'bin'不是公认的内部或外部命令。在我问之前试过这个。
答案 0 :(得分:1)
您可以调用相同命令的两种略有不同的方式:
rake db:migrate RAILS_ENV=development
会丢弃'bin'元素并且无论如何都应该正常工作。
或bundle exec rake db:migrate RAILS_ENV=development
使用bundle exec在项目中运行命令。
确保从正确的目录运行这样的命令,从项目的根目录运行rails server
等目录。
答案 1 :(得分:0)
您可以尝试:
ActiveRecord::Migrator.migrate("db/migrate/", nil)