简体   繁体   中英

Ruby uninitialized constant Pipl::Person (NameError)

I am trying to integrate the Pipl API into my ruby on rails application. I am using ruby version 2.3.4 and rails 4.2.5. As a reference i looked at this site and copied the ruby version of the code directly from it into a ruby file. When I run the ruby file in the terminal i get the error:

`<main>': uninitialized constant Pipl::Person (NameError)

Any ideas why I'm getting this error? Any help is greatly appreciated.

This is the code snippet that I used:

require 'pipl'

person = Pipl::Person.new
person.add_field Pipl::Name.new(first: 'Clark', last: 'Kent')
person.add_field Pipl::Address.new(country: 'US', state: 'KS', city: 
'Smallville')
person.add_field Pipl::Address.new(country: 'US', state: 'KS', city:  
'Metropolis')

response = Pipl::client.search person: person, api_key: 'myKEY' #I used my actual key here

puts "#{response}"

Thanks!

In order to use the Pipl API without the error, I got my API key through their site and I added piplapis-ruby gem just like what was told in the comments above. I imported all of the ruby classes found here: https://github.com/piplcom/piplapis-ruby into my project and pasted the codesnippet.rb file found here: https://github.com/piplcom/piplapis-ruby which was the ruby file you're supposed to execute. There was no need for me to create the Person class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM