everydayrails/everydayrails-rspec-2017

Chapter 10, Geocoder now requires API key for Ipstack

JunichiIto opened this issue · 2 comments

In this book, the VCR cassette simulates a request to freegeoip.io, but freegeoip.io (freegeoip.net) was discontinued on July 1st, 2018. So if you want to recreate the cassette, it fails now.

You need these steps to do so:

  1. Get Ipstack's free API key (See https://ipstack.com/product )
  2. bundle update geocoder
  3. Create config/initializers/geocoder.rb
# config/initializers/geocoder.rb
Geocoder.configure(ip_lookup: :ipstack, api_key: "(your-api-key)")

Please see also:

However the API key is credential, so it must be hidden from geocoder.rb and VCR cassettes in GitHub repository. It might require some more complicated steps😔

That's unfortunate—the only reason I added the geocoding feature to the sample app was so I could develop/test against an API that didn't require readers to get API keys. I'll try to address this in a blog post at least in the next couple of weeks.

Released.