0

Ruby on Rails app deployed on Beanstalk is giving me error for API AI / Dialog Flow Gem:

NameError
uninitialized constant MessengerHireController::ApiAiRuby

I have the following code in my sidekiq Worker:

dialog_client = ApiAiRuby::Client.new(
  :client_access_token => access_token, 
  :api_session_id => @freelancer.user.id
)
response = dialog_client.text_request msg

I have tested it in my regular controller and it doesnt work.

  1. I have moved it out of worker and to standard controller.
  2. It works on my local but not on beanstalk
  3. I ran rails console on beanstalk and tried the same code and it gave me error. I manually installed gem with gem install 'api-ai-ruby' After which it stopped giving me NameError on console, but still doesnt work on production.
  4. I checked with gem list and the gem is installed on production.

My Biggest hypothesis is that the app is unable to find the installed gem.

Thank you in advance for help.

  • How do you run sidekiq in production? like `sidekiq` or `bundle exec sidekiq`? The first way may not load installed gems, for example. – nattfodd Nov 21 '17 at 08:39
  • I moved the method to a regular controller and it still gave the same error. Hence to conclude that the problem is not with Worker. – Aakash Barot Nov 21 '17 at 11:42

1 Answers1

0

You need add gem 'api-ai-ruby' to you gemfile, and run bundle install, otherwise Rails won't load it. See What is the use of Gemfile in rails?

Fangxing
  • 5,716
  • 2
  • 49
  • 53