Uninitialized constant while using gem in rails - ruby-on-rails

I am trying to run the following code to initialize the official EventbriteClient
eb_client = EventbriteClient.new(eb_auth_tokens)
however, I faced the uninitialized constant WelcomeController::EventbriteClient
I double checked and confirmed gem is installed.

Seems like you forget to add this gem to your Gemfile:
gem 'EventbriteClient'

Related

getting godmin-tags gem errors on starting rails

I get the following error when I try to start up rails or if I run rails console.
.rvm/gems/ruby-2.3.3#adventure_map/gems/godmin-tags-1.0.1/lib/godmin/tags/helper.rb:11:in '<module:Godmin>': uninitialized constant Godmin::FormBuilders (NameError)
I have included the gem godmin-tags , using haml for templating and running rails-5.0.1
No issue has been raised on its github page and I can seem to find a solution to this
Part of my Gemfile is:
gem 'godmin-tags'
gem 'godmin' # administrative interface https://github.com/varvet/godmin
gem 'devise_token_auth'
gem 'omniauth'
Make sure you include godmin-tags after godmin ;-)

uninitialized constant Request (NameError)

I get this error: /LiveToChallenge/config/initializers/gibbon.rb:1:in '<top (required)>': uninitialized constant Gibbon::Request (NameError) when I try to start the server rails server.
app/config/initializers/gibbon.rb
require 'gibbon'
Gibbon::Request.api_key = "24e4a2233cd34debb76ed083dc3f8b5379-us8"
Gibbon::Request.timeout = 15
I followed gibbon gem instructions, which seemed simple enough. Maybe I'm missing something besides just gem install gibbon and adding api_key to initializer?
The gem is installed as gibbon (2.2.2, 2.2.1, 1.2.1)
And as added measure I put gem gibbon in the gemfile and ran bundle install
This problem is part of a larger problem I've been working on solving.
I experienced same issue with gibbon 2.0 version as it has updated some methods for initializations then i tried a previous version & it worked but first You should try it this way :
gibbon = Gibbon::Request.new(api_key: "MailChimp_API_Key")
gibbon.timeout = 10
If no luck with this in app/config/initializers/gibbon.rb then you can try to do this direct in the controller just before using gibbon to retrieve or add list stuff for testing.
You should add the gem to the rails Gemfile. Then rails will take care of the require 'gibbon' for you.
Edit: gem install gibbon will just install the gem on your system. Rails won't know that it is needed unless you add it to the Gemfile.

Rails Gem not loading in rails app

I have written my own Gem called date_ninja which makes sure a date is returned in the correct when passing a date from excel. Testing the gem it works fine. For example opening irb, and calling require 'date_ninja' returns true and I am able to use.
DateNinja::DateDojo.date_format_validation(value).
This will either return an date or an exception.
In my Rails App, I have added the gem to my gemfile as so:
gem 'date_ninja', git: 'git#github.com:mpowered/date_dojo'
I then ran bundle install but when I use it, I get this:
DateNinja::DateDojo.date_format_validation(56423)
NameError: uninitialized constant DateNinja::DateDojo
from (pry):5:in `<main>'
If I open the Rails console and see if I can require 'date_ninja' it => false so I am guessing its not loading my gem even though I have bundled it. Am I missing a step?
Can you try replacing the line:
gem 'date_ninja', git: 'git#github.com:mpowered/date_dojo'
with
gem 'date_ninja', path: 'local/path/of/ninja'
If this works then something is not well set with git.

How to implement twitter-text-rb

Hi I am trying use twitter-text-rb gem.
added "include Twitter::Autolink" in application helper follow by example, after restarting the server getting error
Routing Error
uninitialized constant Twitter::Autolink
Add this to your Gemfile:
gem 'twitter-text'
And then run:
bundle install

Uninitialized Constant in Rails 3.0.1 using the RedCloth 4.2.2 gem

I'm having an issue with using RedCloth in my local application. I keep getting the following error:
uninitialized constant ActionView::CompiledTemplates::RedCloth
This happens because I have the following code:
<%= RedCloth.new("Some text").to_html %>
What I tried to do is put this in the environment.rb file:
require "RedCloth"
However, when I do this, I get a huge error with my Phusion Passenger + Nginx configuration, which I've detailed in the following forum: http://railsforum.com/viewtopic.php?id=42560
Any help would be great. Thanks!
Make sure your Gemfile has a gem 'RedCloth' in it. Regardless of which gems are actually installed in your system, Rails will only use the gems listed in your Gemfile. You do not need the require "RedCloth" statement either.
I had exactly the same error and gem 'RedCloth' line was present in Gemfile. What helped was adding require statement in the beginning of controller file
require 'redcloth'
class StaticController < ApplicationController
...

Resources