Last active
August 29, 2015 14:05
-
-
Save murajun1978/bf868bfe10f507bbda1f to your computer and use it in GitHub Desktop.
気持ち悪いコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
# リファクタリング後 | |
@staff = Staff.new(params[:staff]) | |
if staff = Staff.find_by(email: @staff.email) | |
session[:staff_id] = staff.id | |
redirect :root | |
else | |
render :new | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
# リファクタリング後 | |
@staff = Staff.new(params[:staff]) | |
render :new and return if @staff.email.blank? | |
staff = Staff.find_by(email: @staff.email) | |
session[:staff_id] = staff.id | |
redirect :root | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@staff = Staff.new(params[:staff]) | |
if @staff.email.present? | |
staff = Staff.find_by(email: @staff.email) | |
end | |
if staff | |
session[:staff_id] = staff.id | |
redirect :root | |
else | |
render :new | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment