Note that there are some explanatory texts on larger screens.

plurals
  1. PORuby on Rails fb_graph failing with undefined method bytesize when executed from delayed_job
    text
    copied!<p>I am using a combo of <code>omniauth</code> and <code>delayed_job</code> to integrate with Facebook. I have an <code>Authentication</code> model that looks a little bit like this:</p> <pre><code>class Authentication &lt; ActiveRecord::Base def account @account ||= FbGraph::User.me(token) end def post_to!(opts = {}) account.feed!(opts) end end </code></pre> <p>So then from the console I can do something like this:</p> <pre><code>auth.post_to :message =&gt; 'Foo bar', :link =&gt; 'http://google.com' </code></pre> <p>... and everything works perfectly and an update is posted to my Facebook feed.</p> <p>However, in the application I have created a custom delayed job that does exactly the above, only it fails every time with the following error stack:</p> <pre><code>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'' </code></pre> <p>I have officially got to the point where I start throwing expensive computers out of the window. Can anyone offer any insight as to why it's failing, why it works when executed from the console but fails when executed from a custom delayed_job?</p> <p>Any help is greatly appreciated. Thank you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload