1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Rails】gimei(Gem)について

Posted at

記事概要

Ruby on Railsのgimei(Gem)について、まとめる

前提

  • Ruby on Railsでアプリケーションを作成している

gimeiとは

さまざまな意図に応じた、ランダムな値を日本語で生成するGem

Gemのインストール手順

Gemfileの記述

手順

  1. spec/factories/[モデル名の複数形].rbに、コードを記述する
    FactoryBot.define do
      gimei = Gimei.name
      factory :user do
        last_name             {gimei.last.kanji}
        last_name_kana        {gimei.last.katakana}
    	email                 {Faker::Internet.email}
        password              {Faker::Internet.password(min_length: 6)}
        password_confirmation {password}
      end
    end
    
  2. ランダムな値を日本語で生成する
    irb(main):001:0> user = FactoryBot.build(:user)
    => #<User id: nil, last_name: "市川", last_name_kana: "イチカワ", email: "deja_grimes@johnson-rohan.example", created_at: nil, updated_at: nil>
    

Ruby on Railsまとめ

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?