NameError (uninitialized constant MyController::ApiAiRuby):
I'm getting the following error when trying to activate the controller action that executes the api call:
`NameError (uninitialized constant MyController::ApiAiRuby):
app/controllers/maya_controller.rb:5:in my_action' Rendering /var/lib/gems/2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout Rendering /var/lib/gems/2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_source.html.erb Rendered /var/lib/gems/2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (5.5ms) Rendering /var/lib/gems/2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb Rendered /var/lib/gems/2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.3ms) Rendering /var/lib/gems/2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb Rendered /var/lib/gems/2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.0ms) Rendered /var/lib/gems/2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (22.9ms)
My controller looks as follows:
class MyController < ApplicationController
skip_before_action :verify_authenticity_token
def my_action
client = ApiAiRuby::Client.new(
:client_acess_token => '###############################'
)
response = client.text_request "#{params[:transcript]}"
result = response[:result]
Rails.logger.debug("#{response}")
respond_to do |format|
format.js {}
end
end
end
It blocks the request to API.AI what is going on?
+1 I have the same issue on Beanstalk. Did you find any solution ?
It works on my local but doesn't work on production.
Here is the link to my question on Stack: https://stackoverflow.com/questions/47401185/nameerror-uninitialized-constant-apiairuby
@aakashbarot To this date I have not found a solution but I did find a workaround.
This behavior happened when creating a new project and trying to replicate the integration with API.AI that I had previously accomplished on another project.
I was unable to accomplish the integration, the weird thing is that after cloning my previous project with the same config it did work.
Here is the repo that worked back in september:
https://github.com/jorgecuevas92/api_ai_rails
You would just have to change the client access token as the one in the code has been obsolete for some time.
Help yourself to the code and check if you can run it on a production environment without problems, maybe you can work it from there.
Let me know if I can help you further in anyway.
I did the same thing and it didn't work.
I have to switch to a previous version of the gem 1.3 and then it worked.