comparison app/controllers/tweets_controller.rb @ 48:8983c426e256

Prevent exploding on empty timeline.
author nanaya <me@myconan.net>
date Thu, 23 Apr 2015 16:14:35 +0900
parents 9e03bbbb1d43
children 8f68ca606099
comparison
equal deleted inserted replaced
47:e5082c4c234d 48:8983c426e256
1 class TweetsController < ApplicationController 1 class TweetsController < ApplicationController
2 def index 2 def index
3 end 3 end
4 4
5 def show 5 def show
6 @tweets = Tweet.new(params[:id]).timeline 6 client = Tweet.new(params[:id])
7 7 @tweets = client.timeline
8 @user = @tweets.first.user 8 @user = client.user
9 rescue Twitter::Error::NotFound 9 rescue Twitter::Error::NotFound
10 head :not_found 10 head :not_found
11 rescue Twitter::Error::Unauthorized 11 rescue Twitter::Error::Unauthorized
12 head :forbidden 12 head :forbidden
13 end 13 end