Validation Rails、PostgreSQL、Heroku-如何更改空=>;假;规则?
我正在本地主机上开发我的应用程序(Rails 3.2,PostgreSQL 9.1),在那里一切都很好,所以我决定将该应用程序部署到Heroku的生产环境中 成功部署应用程序后,我尝试创建一个新项目,并收到以下错误消息:Validation Rails、PostgreSQL、Heroku-如何更改空=>;假;规则?,validation,heroku,authlogic,ruby-on-rails-3.2,postgresql-9.1,Validation,Heroku,Authlogic,Ruby On Rails 3.2,Postgresql 9.1,我正在本地主机上开发我的应用程序(Rails 3.2,PostgreSQL 9.1),在那里一切都很好,所以我决定将该应用程序部署到Heroku的生产环境中 成功部署应用程序后,我尝试创建一个新项目,并收到以下错误消息: ActiveRecord::StatementInvalid (PG::Error: ERROR: null value in column "persistence_token" violates not-null constraint 它是关于表Users(使用Auth
ActiveRecord::StatementInvalid (PG::Error: ERROR: null value in column "persistence_token" violates not-null constraint
它是关于表Users
(使用Authlogic
gem)。这是迁移的示例-关键部分:
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :name, :null => false
t.string :email, :null => false
t.string :crypted_password, :default => nil, :null => true
t.string :password_salt, :default => nil, :null => true
t.string :email, :default => nil, :null => true
t.string :persistence_token, :null => false
t.string :single_access_token, :null => false
t.string :perishable_token, :null => false
t.datetime :last_request_at
t.datetime :current_login_at
t.datetime :last_login_at
t.string :current_login_ip
t.string :last_login_ip
t.timestamps
end
end
end
class CreateUsersfalse
t、 字符串:email,:null=>false
t、 字符串:加密的密码,:default=>nil,:null=>true
t、 字符串:password\u salt,:default=>nil,:null=>true
t、 字符串:email,:default=>nil,:null=>true
t、 字符串:persistence\u标记,:null=>false
t、 字符串:单\u访问\u令牌,:null=>false
t、 字符串:易腐_标记,:null=>false
t、 日期时间:上次请求时间
t、 日期时间:当前登录时间
t、 日期时间:上次登录时间
t、 字符串:当前\u登录\u ip
t、 字符串:上次登录\u ip
t、 时间戳
结束
结束
结束
是什么导致了这个问题?我的意思是,我在迁移中看到了规则:null=>false
,错误消息说保存到该列中的null值,但是如何在localhost上工作良好而在Heroku上不工作呢
那么,我该如何解决这个问题呢?我的第一个想法是创建一个新的迁移,在这里我为该列设置了
:null=>true
,但它是否正确?我将默认值设置为default'
,错误消失了…设置:null=>true
只允许列中的null
值,跟踪原始问题并打开一罐蠕虫。