我正在使用 Facebook 的组合omniauth
并delayed_job
与 Facebook 集成。我有一个Authentication
看起来有点像这样的模型:
class Authentication < ActiveRecord::Base
def account
@account ||= FbGraph::User.me(token)
end
def post_to!(opts = {})
account.feed!(opts)
end
end
那么从控制台我可以做这样的事情:
auth.post_to :message => 'Foo bar', :link => 'http://google.com'
... 一切正常,更新已发布到我的 Facebook 提要。
但是,在应用程序中,我创建了一个完全执行上述操作的自定义延迟作业,只是每次都会失败,并出现以下错误堆栈:
undefined method `bytesize'' for nil:NilClass
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/activesupport-3.1.3/lib/active_support/whiny_nil.rb:48:in `method_missing''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/httpclient-2.2.4/lib/httpclient/http.rb:830:in `block in escape''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/activesupport-3.1.3/lib/active_support/core_ext/string/output_safety.rb:142:in `gsub''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/activesupport-3.1.3/lib/active_support/core_ext/string/output_safety.rb:142:in `gsub''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/httpclient-2.2.4/lib/httpclient/http.rb:829:in `escape''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/httpclient-2.2.4/lib/httpclient/http.rb:822:in `block in escape_query''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/httpclient-2.2.4/lib/httpclient/http.rb:818:in `each''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/httpclient-2.2.4/lib/httpclient/http.rb:818:in `collect''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/httpclient-2.2.4/lib/httpclient/http.rb:818:in `escape_query''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/httpclient-2.2.4/lib/httpclient/http.rb:809:in `create_query_part_str''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/httpclient-2.2.4/lib/httpclient/http.rb:538:in `set_content''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/httpclient-2.2.4/lib/httpclient/http.rb:447:in `init_request''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/httpclient-2.2.4/lib/httpclient/http.rb:705:in `new_request''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/httpclient-2.2.4/lib/httpclient.rb:997:in `create_request''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/httpclient-2.2.4/lib/httpclient.rb:866:in `do_request''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/httpclient-2.2.4/lib/httpclient.rb:756:in `request''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/httpclient-2.2.4/lib/httpclient.rb:666:in `post''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/fb_graph-2.4.7/lib/fb_graph/node.rb:55:in `block in post''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/fb_graph-2.4.7/lib/fb_graph/node.rb:122:in `handle_response''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/fb_graph-2.4.7/lib/fb_graph/node.rb:54:in `post''
/Users/aaron/.rvm/gems/ruby-1.9.2-p290@bb/gems/fb_graph-2.4.7/lib/fb_graph/connections/feed.rb:15:in `feed!''
/Users/aaron/Sites/bb/app/models/authentication.rb:40:in `post_to!''
/Users/aaron/Sites/bb/lib/share_activity_job.rb:39:in `block in perform''
/Users/aaron/Sites/bb/lib/share_activity_job.rb:11:in `each''
/Users/aaron/Sites/bb/lib/share_activity_job.rb:11:in `perform''
我已经正式到了开始将昂贵的计算机扔出窗外的地步。任何人都可以提供任何关于它为什么失败的见解,为什么它在从控制台执行时工作但在从自定义延迟作业执行时失败?
任何帮助是极大的赞赏。谢谢你。