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

More than 5 years have passed since last update.

gem 'devise' デバイス実装の流れ自分メモ

Last updated at Posted at 2019-05-29

まずデータベース作成した後

gemfile.rb
gem 'devise'
terminal.rb
$ bundle install
$ rails generate devise:install

$ rails g controller home(このタイミングでコントローラーを作成した)

development.rb

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
terminal.
rails g devise モデル名

create    db/migrate/20190529070217_devise_create_users.rb

このようにマイグレーションファイルが作成されるのでこれをdb:migrateして反映させる

== 20190529070217 DeviseCreateUsers: migrating ================================
-- create_table(:users)
-> 0.0015s
-- add_index(:users, :email, {:unique=>true})
-> 0.0008s
-- add_index(:users, :reset_password_token, {:unique=>true})
-> 0.0009s
== 20190529070217 DeviseCreateUsers: migrated (0.0035s) =======================

*localhost3000/users/sign_upしてみる

application_controller.rb
before_action :authenticate_user!

認証していないとアクセスを弾くコマンド

ただトップページだけは認証されていなくとも表示したいので、

home_controller.rb
class HomeController < ApplicationController
  skip_before_action :authenticate_user!
  def index
  end
end

としておく。

ここからtaskのモデルを作っていこうと思う

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