Skip to content

Uninitialized constant RingCentralSdk::REST using Rails console #71

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

Open
grokify opened this issue Jan 30, 2018 · 6 comments
Open

Uninitialized constant RingCentralSdk::REST using Rails console #71

grokify opened this issue Jan 30, 2018 · 6 comments

Comments

@grokify
Copy link
Owner

grokify commented Jan 30, 2018

Reported on the RingCentral Developers Glip team:

I'm having troubles using it in the rails console. I'm getting the error
"Uninitialized constant RingCentralSdk::REST"

I can use the gem inside some .rb file or in irb after requiring it there. But am having troubles using it in a service

@grokify
Copy link
Owner Author

grokify commented Jan 30, 2018

@DorianKwan
Copy link

Thank you @grokify, but both of those links do not help this issue. Yes, they talk about the error itself. But they don't provide much substance in the scope of this problem.

The issue at hand is the use of the RingCentralSdk module 'REST'.

If I were to open an new irb session, I would need to require 'ringcentral_sdk'. Then I could use the gem as intended. ::REST would not throw an uninitialized constant error. Same if I were to create some_file.rb and require 'ringcentral_sdk' within that file.

The problem is when added it to a Ruby service (In my case). Where I would test it out by starting the rails console. But when I call SomeService.new(). I will be thrown the error as described above.

Note, I have the RC API configuration and OAuth being handle in the initialize method.

@grokify
Copy link
Owner Author

grokify commented Jan 30, 2018

Can you provide a minimal Rails app with ringcentral_sdk that exhibits the error?

I don't use Rails and while I've installed it and created a controller, it may take a while to get a minimal app running. I generally use Sinatra. If not, I'll still look into this, but it may take longer.

@DorianKwan
Copy link

DorianKwan commented Jan 30, 2018

@grokify You can get a minimal rails app going in less than 30 minutes. There is a beautiful thing with rails scaffolding where you type a few commands and boom. Minimal rails app.

I will not be able to create this for you until later today or tomorrow.

@grokify
Copy link
Owner Author

grokify commented Jan 30, 2018

The devil is in the details ;)

I have a simple app running, but I don't know how to even instantiate the SDK yet.

My first attempt is to load it in a controller where I get the following error:

ArgumentError (bad argument (expected URI object or URI string)):
  
app/controllers/welcome_controller.rb:5:in `new'

Here's the controller. The simple variable assignments work, just not instantiating the SDK.

require 'ringcentral_sdk'

class WelcomeController < ApplicationController
  def index
    client = RingCentralSdk::REST::Client.new do |config|
      # config here
    end
    @ringcentral_sdk_version = RingCentralSdk::VERSION
    @ringcentral_production_server = RingCentralSdk::RC_SERVER_PRODUCTION
    @ringcentral_sandbox_server = RingCentralSdk::RC_SERVER_SANDBOX
  end
end

@DorianKwan
Copy link

Ahh, my bad @grokify

In this case, I do believe using a ruby service is the way to reproduce my error.

I'll send you the code in Glip

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