nov / fb_graph

This gem doesn't support FB Graph API v2.0+. Please use fb_graph2 gem instead.
MIT License
1.04k stars 191 forks source link

Ruby 2.0 + Rails 4.0 result in undefined method 'meta_add_field' #330

Closed pawelkomarnicki closed 11 years ago

pawelkomarnicki commented 11 years ago

Hmm I was trying to run any example, but I keep getting this error all the time:

NoMethodError: undefined method `meta_add_field' for "":String
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/httpclient-2.3.3/lib/httpclient/http.rb:236:in `set_body_encoding'
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/httpclient-2.3.3/lib/httpclient/http.rb:325:in `set_headers'
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/httpclient-2.3.3/lib/httpclient.rb:1138:in `do_get_header'
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/httpclient-2.3.3/lib/httpclient.rb:1086:in `do_get_block'
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/httpclient-2.3.3/lib/httpclient.rb:887:in `block in do_request'
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/httpclient-2.3.3/lib/httpclient.rb:981:in `protect_keep_alive_disconnected'
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/httpclient-2.3.3/lib/httpclient.rb:886:in `do_request'
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/httpclient-2.3.3/lib/httpclient.rb:774:in `request'
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/httpclient-2.3.3/lib/httpclient.rb:677:in `get'
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/fb_graph-2.7.7/lib/fb_graph/node.rb:50:in `block in get'
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/fb_graph-2.7.7/lib/fb_graph/node.rb:123:in `handle_response'
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/fb_graph-2.7.7/lib/fb_graph/node.rb:49:in `get'
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/fb_graph-2.7.7/lib/fb_graph/node.rb:19:in `fetch'
    from (irb):1
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
    from /Users/pawelkomarnicki/.rvm/gems/ruby-head/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'head
nov commented 11 years ago

Ruby 2.0 (2.0.0-p247) seems fine.

nov.matake@tovl ~$ pry
[1] pry(main)> RUBY_VERSION
=> "2.0.0"
[2] pry(main)> require 'open-uri'
=> true
[3] pry(main)> OpenURI::Meta.init(o = '')
=> nil
[4] pry(main)> o.methods.grep /meta/
=> [:meta, :meta_setup_encoding, :meta_add_field]

Rails 4.0 on Ruby 2.0 also seems fine.

nov.matake@tovl x$ r c
Loading development environment (Rails 4.0.0)
irb(main):001:0> OpenURI::Meta.init(o = '')
=> nil
irb(main):002:0> o.methods.grep /meta/
=> [:meta, :meta_setup_encoding, :meta_add_field]

I guess it's your environment specific issue.

nov commented 11 years ago

any updates? or can I close this issue?

svoboda-jan commented 11 years ago

Hi, I've been testing fb_graph with ruby 2.1.0dev (2013-09-22 trunk 43011) [x86_64-darwin12.4.0] and get the same error.

eamonn-webster commented 11 years ago

Looks like meta_add_field has been replaced with meta_add_field2. What's more while meta_add_filed took a name and a value meta_add_field2 takes a name and an array of values

I have submitted a patch http://bugs.ruby-lang.org/issues/9051

svoboda-jan commented 11 years ago

@eamonn-webster Thanks for the clarification. Based on the patch, it should be possible to temporarily fix it on 2.1dev with the following code (untested):

module OpenURI::Meta
  def meta_add_field(name, value)
    meta_add_field2(name, [value])
  end
end

Also, I found an open PR about this in httpclient: https://github.com/nahi/httpclient/pull/180

eamonn-webster commented 11 years ago

That is what I did in my patch.