flickr-fu 简单示例不起作用
我在 Rails 应用程序中使用 flickr-fu gem 进行 flickr api 集成。我按照如下所示的设置 Web 应用程序的示例代码进行操作:
def flickr_create
flickr = Flickr.new(File.join(RAILS_ROOT, 'config', 'flickr.yml'))
redirect_to flickr.auth.url(:read)
end
def flickr_callback
flickr = Flickr.new(File.join(RAILS_ROOT, 'config', 'flickr.yml'))
flickr.auth.frob = params[:frob]
current_user.update_attribute :flickr_token, flickr.auth.token.token
flash[:notice] = "Succesfully authenticated with Flickr"
redirect_to :flickr_stream
end
我已将 flickr_callback 注册为 flickr 在授权过程后调用的回调方法。
当我尝试将 params[:frob] 分配给 flickr.auth.frob 时,问题出在 flickr_callback 中的行。我收到以下错误:
Flickr::Auth:0x24b3640 的未定义方法“frob=”
即使我只需要从控制台中调用'flickr_fu',创建一个新的 flickr 实例,并尝试分配给 frob,我也会得到同样的错误。我查看了github上的gem源代码,setter frob=是在Flickr::Auth模块中设置的,所以我不知道错误在哪里。 API 调用成功,flickr 对象初始化正常。
I'm using flickr-fu gem within a rails application for flickr api integration. I'm following the sample code for setting up a web app shown below:
def flickr_create
flickr = Flickr.new(File.join(RAILS_ROOT, 'config', 'flickr.yml'))
redirect_to flickr.auth.url(:read)
end
def flickr_callback
flickr = Flickr.new(File.join(RAILS_ROOT, 'config', 'flickr.yml'))
flickr.auth.frob = params[:frob]
current_user.update_attribute :flickr_token, flickr.auth.token.token
flash[:notice] = "Succesfully authenticated with Flickr"
redirect_to :flickr_stream
end
I've registered flickr_callback as the callback method that flickr calls after the authorization process.
The problem is with the line in flickr_callback when I try and assign params[:frob] to flickr.auth.frob. I get the following error:
undefined method `frob=' for Flickr::Auth:0x24b3640
Even if I just require 'flickr_fu' from within console, create a new flickr instance, and attempt to assign to frob, I get the same error. I took a look at the gem source on github, and the setter frob= is set within the Flickr::Auth module, so I'm clueless as to where the error is. The API calls work successfully and the flickr object is initialized fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是来自gemcutter或github的flickr-fu gem版本为0.1.4,并且frob setter方法直到后续版本才实现。相反,从 github 安装 gem commonthread-flickr_fu v0.3.0,并且 frob 是可写的。
The issue is that the flickr-fu gem from gemcutter or github is at version 0.1.4, and the frob setter method wasn't implemented until subsequent version. Instead install the gem commonthread-flickr_fu v0.3.0 from github, and the frob is writeable.