我是新來的Rails,請耐心等待。ActiveRecord :: PendingMigrationError - 從一臺服務器遷移到另一臺服務器
目前在數字海洋虛擬機(Ubuntu 14.04)上運行的現有項目(Rails 4.1.6,Ruby 2.1.3)及其與Postgresdb 9.6的連接沒有任何問題。我必須將其遷移到新的VM。
我已經在Ubuntu 16.04上安裝了一個新的虛擬機,安裝了完全相同版本的Rails和Ruby。我試圖創建一個測試軌應用程序,它的工作正常。但是,當我試圖從舊服務器部署項目到這個新的它給我錯誤。
Details:
There was an error while trying to load the gem 'uglifier'.
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Backtrace for gem load error is:
/usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.7.0/lib/execjs /runtimes.rb:58:in `autodetect'
/usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
/usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'
/usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.6/lib /active_support/dependencies.rb:247:in `require'
/usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `block in require'
/usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'
互聯網上搜索後,他們大多建議取消註釋中的Gemfile此行。
# gem 'therubyracer', platforms: :ruby
這是在舊的服務器上評論,但是,我試圖取消註釋它,它回來了不同的錯誤。
Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development
網站連接到相同的數據庫和舊的webportal運行良好,但它給了我這個錯誤。所以,我建立一個新的測試數據庫和運行以下命令 -
RAILS_ENV=production bundle exec rake db:create
RAILS_ENV=production bundle exec rake db:setup
RAILS_ENV=production bundle exec rake db:migrate
所有這些命令成功執行,但由於某種原因,我仍然收到「遷移正在等待......」的錯誤。
請指教。
當您說「運行測試」時,您的意思是rspec測試還是其他自動測試? –
遷移錯誤似乎認爲您應該在'development'環境中......但是您所運行的遷移是針對'production' ......因此,無論您的環境設置不正確,還是需要運行遷移爲'發展'而不是 –
@Taryn東謝謝..我真是太愚蠢了。我檢查了nginx站點可用的文件,並且乘客env被設置爲開發。我改變了它的生產,它像一個魅力。 – Sai