GemのSoceryを使ってログイン機能を付けています。
http://dev.classmethod.jp/server-side/ruby-on-rails/ruby-on-rails_sorcery_auth_no1/
こちらの記事のログイン、ログアウトのセッション機能の部分
app/controllers/user_sessions_controller.rb 内の
class UserSessionsController < ApplicationController def new @user = User.new end def create if @user = login(params[:email], params[:password]) redirect_back_or_to(:users, notice: 'Login successful') else flash.now[:alert] = 'Login failed' render action: 'new' end end def destroy logout redirect_to(:users, notice: 'Logged out!') end end
のnewアクションで@userというインスタンス変数を作っている意味は何でしょうか?
createの所でもif文で使われていますがこの@userという変数が存在する意味がわからなかったので質問させてもらいます。
あなたの回答
tips
プレビュー