我最近添加了devise confirmable模塊到我的rails應用程序。我的應用程序在dev中運行良好。但是,當我將它推向heroku時,它會說:「我們很抱歉,但出了問題。」以下是我的英雄日誌 -heroku rails應用程序數據庫遷移問題
Rendered devise/confirmations/new.html.erb within layouts/application (2.7ms)
2012-02-03T01:55:07+00:00 app[web.1]: Rendered devise/shared/_links.erb (0.5ms)
2012-02-03T01:55:07+00:00 app[web.1]: cache: [GET /users/confirmation/new] miss
2012-02-03T01:55:07+00:00 app[web.1]: Completed 200 OK in 19ms (Views: 16.9ms | ActiveRecord: 0.0ms)
2012-02-03T01:55:07+00:00 heroku[router]: GET personaldiary.herokuapp.com/users/confirmation/new dyno=web.1 queue=0 wait=0ms service=42ms status=200 bytes=1540
2012-02-03T01:55:11+00:00 app[web.1]:
2012-02-03T01:55:11+00:00 app[web.1]:
2012-02-03T01:55:11+00:00 app[web.1]: Started POST "https://stackoverflow.com/users/confirmation" for 50.131.164.83 at 2012-02-03 01:55:11 +0000
2012-02-03T01:55:11+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"iVVTpWgIrBTR8b9k07lr2tYDFQfAYD0R8JmGVkmfzl4=", "user"=>{"email"=>"[email protected]"}, "commit"=>"Resend confirmation instructions"}
2012-02-03T01:55:11+00:00 app[web.1]: Processing by Devise::ConfirmationsController#create as HTML
2012-02-03T01:55:11+00:00 app[web.1]: Completed 500 Internal Server Error in 4ms
2012-02-03T01:55:11+00:00 app[web.1]:
2012-02-03T01:55:11+00:00 app[web.1]: NameError (undefined local variable or method `confirmed_at' for #<User:0x000000023254e0>):
2012-02-03T01:55:11+00:00 app[web.1]:
2012-02-03T01:55:11+00:00 app[web.1]: cache: [POST /users/confirmation] invalidate, pass
2012-02-03T01:55:11+00:00 app[web.1]:
很明顯,該數據庫沒有「confirmed_at」列。我的遷移文件如下:
class AddConfirmableToDeviseV1 < ActiveRecord::Migration
def up
add_column :users, :confirmation_token, :string
add_column :users, :confirmed_at, :datetime
add_column :users, :confirmation_sent_at , :datetime
add_index :users, :confirmation_token, :unique => true
end
def down
remove_index :users, :confirmation_token
remove_column :users, :confirmation_sent_at
remove_column :users, :confirmed_at
remove_column :users, :confirmation_token
end
end
我的產量在Heroku託管:
於是我就
heroku run rake db:migrate
它給了我無輸出。
然後我跑
heroku run rake db:rollback
它給了我
== AddConfirmableToDeviseV1: reverting =======================================
-- remove_index(:users, :confirmation_token)
rake aborted!
An error has occurred, this and all later migrations canceled:
Index name 'index_users_on_confirmation_token' on table 'users' does not exist
Tasks: TOP => db:rollback
此外,
heroku run rake db:migrate --trace
給了我以下
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
** Invoke db:schema:dump (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:schema:dump
任何想法如何解決這個問題?
你可以使用--trace運行db:migrate並查看是否有輸出? – 2012-02-03 03:21:37
**調用分貝:遷移(FIRST_TIME) **調用環境(FIRST_TIME) **執行環境 **調用分貝:load_config(FIRST_TIME) **調用RAILS_ENV(FIRST_TIME) **執行RAILS_ENV **執行DB:load_config **執行分貝:遷移 **調用數據庫:模式:轉儲(FIRST_TIME) **調用環境 **調用數據庫:load_config **執行DB:架構:甩 – riship89 2012-02-03 03:24:03
你有多個應用程序的設置在Heroku? – 2012-02-03 03:32:09