Feb 5, 2021 12:04 PM - edited Feb 5, 2021 12:06 PM
I am trying to use the Hubspot API Ruby gem located here https://github.com/HubSpot/hubspot-api-ruby#installation, but I am having issues with Ruby on Rails.
For all of my other gems, I can just simply add the gem in the Gemfile and it works within the application, but not this case and I cannot figure out why.
For example, here's what I have in my Gemfile:
# HubSpot API Client gem 'hubspot-api-client'
I have ran `bundle install` and it installed successfully, but I still can't use that gem. If I load the gem via the `irb` console, then it works just fine.
Here's what I mean:
root@8af3866a29c8:/myapp# irb irb(main):001:0> require 'hubspot-api-client' => true irb(main):002:0> Hubspot => Hubspot
Using Rails Console
root@8af3866a29c8:/myapp# rails c Running via Spring preloader in process 6589 Loading development environment (Rails 5.2.4) irb(main):001:0> require 'hubspot-api-client' Traceback (most recent call last): 1: from (irb):1 LoadError (cannot load such file -- hubspot-api-client) irb(main):001:0> Hubspot Traceback (most recent call last): 1: from (irb):1 NameError (uninitialized constant Hubspot) irb(main):002:0>
Why does this happen and how do I fix this?
Mar 12, 2021 5:38 AM
Hey, sorry to hear that you're still struggling with this!
Idk what version you're running or what changes you made to the default setup, but I just ran created a fresh app like so:
rails new test_app cd test_app bundle install rails webpacker:install
which yields a functioning base app.
Then I added
to my Gemfile and then issued another
And right away if I launch into the rails console, I get the expected behavior.
Rails automatically loads the gems in your Gemfile.
Just out of curiousity, if you do a fresh install like this (with no other changes), do you still have the same issue?
Feb 8, 2021 8:52 AM
I think your issue might be related to requiring the gem in console. This article might help you out... https://www.ombulabs.com/blog/rails/ruby/how-to-use-any-gem-in-production-console.html
Feb 5, 2021 4:59 PM
I am a fan of the music of alt j
I took a class on ruby on rails about 15 years ago. (I am old) so I am of no help in answering this, but I can attempt to summon the Ruby folks of the Community
(please imagine that was a scene from Lord of the Rings)
Feb 5, 2021 5:09 PM
Haha thanks @dennisedson! Hoping they can provide some help. Over the last few hours I've been writing my own library to interact with the API over GET/POST requests and would prefer to avoid duplicating work lol.
Feb 5, 2021 5:11 PM - edited Feb 5, 2021 5:12 PM