12
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

FactoryGirlでpassword_confirmationを設定する

Posted at

factory_girlでパスワードのペアのような"confirmation => true"なカラムをセットするには以下のように書く。

qiita.rb
# coding: utf-8

FactoryGirl.define do
  factory :user, :class => User do |f|
    f.sequence(:email) {|n| "email#{n}@domain.tld" }
    f.password "password"
    f.password_confirmation { |u| u.password }
    f.status User::ACTIVE
  end
end
12
9
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
12
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?