⭐️Sorcery導入の流れ
Soceryをインストール
# Gemfile
gem 'sorcery'
→bundle install
$ bundle exec rails g sorcery:install
sorceryに用意されているこちらのコマンドを打つことで最低限必要なファイルが生成する。「config/initialize/sorcery.rb」や「db/migrate/20xxxxxxxx_sorcery_core.rb」などなど。
DBに追加情報などを追記する。
# 20xxxxxxx_sorcery_core.rb
classSorceryCore <ActiveRecord::Migration[5.2]
defchange
create_table :usersdo |t|
t.string :email, null: false
t.string :crypted_password
t.string :salt
t.string :first_name 追加情報
t.string :last_name 追加情報
t.timestamps null: false
end
add_index :users, :email, unique: true よく利用するカラムのデータ収集をしやすくする
end
end
参考文献:https://qiita.com/mmaumtjgj/items/9f4fca618d2f395f985e
https://qiita.com/tech_hack_Rich/items/01662f33c9ed405fa51b
DBの操作文献:https://qiita.com/azusanakano/items/a2847e4e582b9a627e3a