【发布时间】:2011-09-17 21:53:11
【问题描述】:
我想在 rails 中使用 youtube 的 api。
我需要一个能够访问 youtubes api 应用程序范围的客户端。 因此我编写了以下应用程序控制器
require 'gdata'
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :auth
def auth
@client = GData::Client::YouTube.new
@client.clientlogin('usermail', 'password')
@client
end
end
我现在可以在扩展 ApplicationController 的控制器中使用客户端。 那工作正常。 但它很慢。
有没有办法进行一次身份验证并在应用程序范围内使用它,而不是在我调用方法之前每次都调用 before_filter?
最好的,
菲利普
【问题讨论】: