Ruby 条件分岐をシンプルに記述する
Rubocopに教えてもらったこと。
修正前
def move_to_signIn
unless user_signed_in?
redirect_to new_user_session_path
end
end
修正後
def move_to_signIn
return if user_signed_in?
redirect_to new_user_session_path
end
returnを使ってシンプルに。
この記事が気に入ったらサポートをしてみませんか?