NameError (uninitialized constant OAuth Did you mean? OAuth2) - oauth-2.0

I'm trying to use omniauth-linkedin-oauth2 on RoR 5.0.7.
gem 'devise'
gem 'omniauth'
gem 'omniauth-oauth2'
gem 'omniauth-linkedin-oauth2'
but I got an error on production environment and I can not start rails apps. My local developing environment is no problem to run it.
The error on production.log is
NameError (uninitialized constant OAuth Did you mean? OAuth2)
if I replaced
gem 'omniauth-linkedin-oauth2'
to
gem 'omniauth-linkedin'
and bundle update then there is no errors and RoR is running.
My production environment is
Debian GNU/Linux 8.11 (jessie)
Apache/2.4.10 (Debian)
Phusion_Passenger/6.0.2
ruby 2.4.6p354

You need to clear the session data to remove the existing OAuth token data. You can't use both token types simultaneously.
Per your comment (leaving an answer in case someone else has this same problem) you need to run:
RAILS_ENV=production rake db:sessions:clear

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 ;-)

Deploying Rails ActionCable using AWS Elastic Beanstalk

I'm trying to deploy the chat demo from DHH on AWS Elastic Beanstalk. I've followed the tutorial here: https://keithpblog.wordpress.com/2015/12/30/rails-5-tutorial-chat-app-can-we-deploy-it And I've managed to get the solution deployed in a single instance and Redis up and running too. But when I try to post something, the message is saved in the db, but not returned by the WebSocket. I've checked the production.log and I can see this error message:
E, [2016-05-20T20:33:52.676577 #24281] ERROR -- : There was an exception - Gem::LoadError(Specified 'redis' for Action Cable pubsub adapter, but the gem is not loaded. Add gem 'redis' to your Gemfile (and ensure its version is at the minimum required by Action Cable).)
E, [2016-05-20T20:33:52.676826 #24281] ERROR -- : /opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/actioncable-5.0.0.rc1/lib/action_cable/server/configuration.rb:37:in `rescue in pubsub_adapter'
/opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/actioncable-5.0.0.rc1/lib/action_cable/server/configuration.rb:34:in `pubsub_adapter'
I also have in my Gemfile:
gem 'redis', '~>3.2'
Any Ideas? Thanks!
I fixed the error by adding to my Gemfile:
gem 'em-hiredis'
gem 'redis'
The other change that I had to make was on /environments/production.rb
config.action_cable.url = 'ws://url.com/cable'
config.action_cable.allowed_request_origins = ['http://url.com']
And with that, I have actioncable up and running on Elastic Beanstalk

Unitialized Constant error when using forked activemerchant gem via Gemfile/github

This morning I forked the activemerchant Ruby gem b/c of a change I needed for my app. My gemfile used to be...
gem 'activemerchant', '~> 1.53.0'
Now it's...
gem 'activemerchant', :github => 'ajporterfield/active_merchant'
However, after running bundle update activemerchant and restarting my Rails server, I'm getting and uninitialized constant ActiveMerchant::Billing::PaypalExpressGateway error.
I am using the Paypal gateway, but my change was a one-liner in the BluePay gateway so I don't think I caused the error with my code change.
Is there an obvious step I'm missing in order to reference a gem from Github in my gemfile?
I'm using Rails 4, Ruby 2.
Thanks!
After revisiting this, I realized my mistake. I had already forked the activemerchant gem - a long time ago. So to fix, I deleted my forked repo and re-forked. Everything's working for me as expected now.

"Cannot load such file" error when deploying Rails app to Heroku

I'm using a gem for gmail in my Rails app. My Gemfile contains:
gem 'gmail-api-ruby', :require => 'Gmail'
And in my controller, I initialize the gem with (using devise/omniauth to get the refresh_token from Google):
Gmail.client_id = ENV['CLIENT_ID']
Gmail.client_secret = ENV['CLIENT_SECRET']
Gmail.refresh_token = current_user.refresh_token
This works fine in development, but when I deploy to Heroku, I get the following error:
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.7.12/lib/bundler/runtime.rb:76:in `require': cannot load such file -- Gmail (LoadError)
I cannot figure out why. Should I be requiring the gem somewhere else in my app?
Ruby 2.2.0
Bundler: 1.8.5
Rails: 4.2.0
require is case sensitive if the underlying filesystem is case sensitive (which it is on linux, which is what underpins heroku)
Change to :require => 'gmail' instead of Gmail and you should be ok.
Just remove useless require option from your Gemfile because bundler can load classes inside of this gem without specify require option in your case.
gem 'gmail-api-ruby', '~> 0.0.10'
and run bundle install.
FYI: read section about require option here.

uninitialized constant Preferences::InstanceMethods::Preference

trying to use in rails3.2.14 and ruby 1.9.3
added gem ’preferences’ to Gemfile and did bundle install
And as per the gem document I do the following step
rails generate migration create_preference
ran rake db:migrate
restarted rails server
added some preference to user model
preference :publish_profile, :default => true
But when tried to access a preference using
#user.prefers_publish_profile
I got uninitialized constant Preferences::InstanceMethods::Preference
Here is the gem url:-
https://github.com/pluginaweek/preferences
The problem will besolved by using rails3 branch gem
gem "preferences", :git
=>"git#github.com:skyeagle/preferences.git",:branch =>"rails3"
Thanks

Resources