changeset 166:469df6354341

A more robust check
author nanaya <me@nanaya.pro>
date Fri, 03 Aug 2018 02:39:09 +0900
parents 5af9b537db86
children 522d832d8a8c
files app/controllers/tweets_controller.rb
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/app/controllers/tweets_controller.rb	Fri Aug 03 02:31:25 2018 +0900
+++ b/app/controllers/tweets_controller.rb	Fri Aug 03 02:39:09 2018 +0900
@@ -1,6 +1,6 @@
 class TweetsController < ApplicationController
   def index
-    return redirect if params[:id] || params[:name]
+    return redirect if params[:id].present? || params[:name].present?
   end
 
   def show
@@ -19,7 +19,7 @@
   end
 
   def redirect
-    @user ||= Tweet.new(params[:id] || params[:name]).user
+    @user ||= Tweet.new(params[:id].presence || params[:name]).user
     redirect_to tweet_path(@user.id, @user.screen_name)
   rescue Twitter::Error::NotFound
     head :not_found