0
2

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 3 years have passed since last update.

devise

Posted at

この記事は初学者が記載しております。

## deviseの使い方を詳しく書く

gemfile

gem 'devise' 

ターミナルにて

bundle install
rails g devise:install

####作成されるfile

config/initializers/devise.rb
config/locales/devise.en.yml

rails g devise コマンドをターミナルにて

rails g devise user

####作成されるfile

app/models/user.rb
db/migrate/2014**********_devise_create_users.rb
test/fixtures/users.yml
test/models/user_test.rb

config/routes.rbに以下の様な記述が自動的に追記されます。

Rails.application.routes.draw do
  devise_for :users

##devise_forとは
ルーティングを一気に生成してくれるヘルパーメソッドです。
この記述によりログインや新規登録が使える様になります。

また、current_userやuser_signed_in?などのヘルパーメソッドも利用できるようになります。

ターミナルにて

 rake db:migrate
0
2
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
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?