Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't convert Pathname into String when using Facebook api in Rails

we are trying to build a facebook app using ruby on rails.

We setup a canvas app and are able to see our app through the canvas, but when we try to integrate the ruby facebook api we get a 'can't convert Pathname into String' error whenever we try to make a request for user data.

We have tried 2 different api's so far (koala and rest-graph) and had the same result.

I even downloaded a working project from koala api sample project

and got the same error. I'm not sure if it is a rails error or because we are trying to run this using rails s localhost:3000

I had a previous ssl error and had to add this code under config/initializers to fix that

require 'open-uri'
require 'net/https'

module Net
  class HTTP
    alias_method :original_use_ssl=, :use_ssl=

    def use_ssl=(flag)
      self.ca_file = Rails.root.join('lib/ca-bundle.crt')
      self.verify_mode = OpenSSL::SSL::VERIFY_PEER
      self.original_use_ssl = flag
    end
  end
end
like image 397
user1327378 Avatar asked Feb 21 '23 20:02

user1327378


1 Answers

The problem is that

self.ca_file

expects a String, while you are sending it a pathname. replace:

Rails.root.join('lib/ca-bundle.crt')

with:

Rails.root.join('lib/ca-bundle.crt').to_s

and it should work

like image 97
lucaronin Avatar answered May 07 '23 02:05

lucaronin