LoginSignup
37
31

More than 5 years have passed since last update.

deviseで作ったusersテーブルにseeds.rbからユーザーを作成する

Posted at

普通に作れるかなと思って以下のように書いたんですが、
rake db:seedしてみるとレコードが追加されていませんでした。

seeds.rb
User.create(:email => 'hogehoge@hoge.com', :encrypted_password => 'xxxxxxxxxxxxxxxxxxx')

次のように修正するとちゃんとレコードが追加されました

seeds.rb
user = User.new(:email => 'hogehoge@hoge.com', :password => 'hugahuga')
user.save!

参考: http://stackoverflow.com/questions/12418584/seeding-users-with-devise-in-ruby-on-rails

37
31
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
37
31