flickr-fu 简单示例不起作用

发布于 2024-08-13 00:12:30 字数 930 浏览 2 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

歌入人心 2024-08-20 00:12:30

问题是来自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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文