From 65920c0f69a8e9ac61899c2212bf087b450bcb07 Mon Sep 17 00:00:00 2001 From: Ruling-Mac Date: Wed, 21 Oct 2015 20:27:43 +0800 Subject: [PATCH] fix bugs --- app/controllers/videos_controller.rb | 6 +----- app/models/video_channel.rb | 3 +++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/videos_controller.rb b/app/controllers/videos_controller.rb index 105e070..ece3373 100644 --- a/app/controllers/videos_controller.rb +++ b/app/controllers/videos_controller.rb @@ -34,11 +34,7 @@ class VideosController < ApplicationController result = JSON.parse(result) vc = [] - video_channels.each do |video_channel| - channel_id = video_channel.channel_link.split("/")[-1] - uri = URI('https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=' + channel_id + '&key=AIzaSyCTFdyLgb7GJfrr1JOI3gvVslZFw7td2zQ') - result = Net::HTTP.get(uri) # => String - result = JSON.parse(result) + result.each do |video_channel| nextPageToken = result['nextPageToken'] rescue "" while !nextPageToken.nil? vc << { diff --git a/app/models/video_channel.rb b/app/models/video_channel.rb index 5660f0f..da009c2 100644 --- a/app/models/video_channel.rb +++ b/app/models/video_channel.rb @@ -13,4 +13,7 @@ class VideoChannel field :channel_link field :description , localize: true + def self.find_by_param(input) + self.find_by(uid: input) + end end \ No newline at end of file