Sign in | Sign up

Nutritionix API 1.1 cannot load such file

Tagged:

Currently contains 4 posts

Avatar

April 23, 2014 17:08

Skinnystork

Hey, I’m using the Ruby on Rails Api 1.1 gem found at https://github.com/JigneshGohel-BoTreeConsulting/nutritionix-api-ruby-library

While I know it’s not an official gem, I’m getting an error trying to instantiate the module as described in the sample script.

require_relative ‘../lib/nutritionix/api_1_1’

def nxql_search_params
fields = %w(brand_id brand_name item_id item_name nf_serving_size_qty nf_serving_size_unit)
fields << %w(nf_calories nf_total_carbohydrate nf_sodium nf_dietary_fiber nf_protein)
default_fields = fields.flatten

{ offset: 0, limit: 50, fields: default_fields }

end

app_id = ‘<YOUR_APP_ID>’
app_key = ‘<YOUR_APP_KEY>’
provider = Nutritionix::Api_1_1.new(app_id, app_key)
search_params = nxql_search_params
search_params.merge!(query: ‘potato’)
results_json = provider.nxql_search(search_params)
puts “Results: #{results_json}”

This gives me the error : LoadError cannot load such file — /xxxxxxx/app/lib/nutritionix/api_1_1 directly on the require_relative line.

I already posted an issue on the github, and also saw that mattsilv also reported a similar issue about a month ago. Has there been any fix to it yet?

Avatar

May 02, 2014 16:06

Matt Silverman

Hi, we do not officially support the RoR library, but we are checking into this. Thanks!

Avatar

August 19, 2014 13:51

ideus_dev

This worked for me:

require_relative ‘../.bundle/ruby/2.0.0/gems/nutritionix-1.1.0/lib/nutritionix/api_1_1’

Avatar

September 05, 2014 00:12

mishatatinets

require ‘nutritionix/api_1_1’

works for me

Reply to thread