We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
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:
Using IRB
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
gem 'hubspot-api-client'
to my Gemfile and then issued another
bundle install
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 9:09 AM
Yeah unfortunately I've tried avoiding the "require" statement and tried including it, and both options seem to lead to the same thing still.
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 7:07 PM
Lol!!
Feb 5, 2021 4:59 PM
2 things
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
@GaryElliott, @ivandhalluin , @creeder , @okodoon can you all help here?
(please imagine that was a scene from Lord of the Rings)
![]() | Make sure to subscribe to our YouTube channel where you can find the HubSpot Community Developer Show |
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
Just so you know, I now know you exist and you will be summoned in the future 😉
(now imagine evil laughter)
![]() | Make sure to subscribe to our YouTube channel where you can find the HubSpot Community Developer Show |