Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError (uninitialized constant MyController::ApiAiRuby): #23

Open
jorgecuevas92 opened this issue Sep 13, 2017 · 3 comments
Open

NameError (uninitialized constant MyController::ApiAiRuby): #23

jorgecuevas92 opened this issue Sep 13, 2017 · 3 comments

Comments

@jorgecuevas92
Copy link

jorgecuevas92 commented Sep 13, 2017

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?

@aakashbarot
Copy link

aakashbarot commented Nov 20, 2017

+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

@jorgecuevas92
Copy link
Author

@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.

@aakashbarot
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants