【发布时间】:2012-02-03 02:03:08
【问题描述】:
我最近在我的 rails 应用程序中添加了设计可确认模块。我的应用程序在开发中运行良好。但是,当我把它推到 heroku 时,它说“我们很抱歉,但出了点问题。”。以下是我的heroku日志-
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 "/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"=>"hrishikeshp19@gmail.com"}, "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 看看有没有输出吗?
-
** 调用 db:migrate (first_time) ** 调用环境 (first_time) ** 执行环境 ** 调用 db:load_config (first_time) ** 调用 rails_env (first_time) ** 执行 rails_env **执行 db:load_config ** 执行 db:migrate ** 调用 db:schema:dump (first_time) ** 调用环境 ** 调用 db:load_config ** 执行 db:schema:dump
-
您是否在 Heroku 中设置了多个应用程序?
-
你在使用 Postgres 和 Heroku 吗?您可以登录数据库并确保 schema_migrations 表中的最新迁移等于或小于您生成的迁移吗?
-
投反对票的人能说出投反对票的理由吗?
标签: ruby-on-rails heroku devise