【发布时间】:2019-02-27 02:59:22
【问题描述】:
我在 heroku 上做了一个 web 应用程序,并尝试通过heroku rake db:seed 添加管理员用户。我可以在应用程序中创建用户,但我不知道如何在种子.rb 中编写好代码。
heroku run rake db:migrate 成功。
截至目前,我无法使用admin 和adminpw 登录。
timestamp_create_user.rb
class CreateUsers < ActiveRecord::Migration[5.2]
def change
create_table :users do |t|
t.string :userid
t.string :email
t.string :password_digest
t.timestamps
end
end
end
seeds.rb
User.create!(
userid: 'admin',
email: 'admin@testing.com',
password: 'adminpw',
passwor_confirmation: 'adminpw',
admin: true
)
heroku 日志
, [2019-02-27T02:46:45.074640 #4] DEBUG -- : (1.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
【问题讨论】:
-
可能存在一些不同的问题。检查您的
password_confirmation拼写...您使用的是设计吗?
标签: ruby-on-rails heroku