Wed, 02 Dec 2015 13:42:34 +0900 投稿
0

【Refactor Me】Controllerをスッキリさせたい

Before

class SessionsController < ApplicationController
  def signin
    @user = User.find_by(email: params[:email])

    if BCrypt::Password.new(@user.password_digest) == params[:password]
      self.current_user = @user
      redirect_to root_path
    else
      flash[:alert] = "Login failed."
      render :new
    end
  end
end

After

# your cool code

みんなのコメント