LoginSignup
4
1

More than 5 years have passed since last update.

(3ステップ)Rails ユーザーのサインアップ機能の作り方

Last updated at Posted at 2018-04-25

deviseを使ってユーザーのサインアップ画面を作る

①deviseのインストール

deviseのgemをインストールします。

Gemfile
gem 'devise' 

bundle installの実行

terminal
$ #プロジェクトファイルのディレクトリに移動
$ bundle install

②ビューファイルの作成

deviseのセットアップをします。

terminal
$ rails g devise:install

deviseのビューファイルを作成します。

terminal
$ rails g devise:views

これでapp>views>devise ←ここにファイルができたはずです。

③ユーザーのモデル作成

ユーザーモデルを作成することで、サインアップ機能を実装できます。

マイグレーションファイルを作成します。

terminal
$ rails g devise user

マイグレーションを実行し、usersテーブルを作成します。

terminal
$ bundle exec rake db:migrate

(サーバーを立ち上げている場合)再起動させます。

terminal
$ (control + c の実行)
$ rails s

http://localhost:3000/users/sign_up にアクセスしてユーザーの作成画面に遷移できるか確認しましょう。

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