Skip to content
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

NameError: uninitialized constant PG #335

Closed
stuxcrystal opened this issue Mar 5, 2019 · 10 comments
Closed

NameError: uninitialized constant PG #335

stuxcrystal opened this issue Mar 5, 2019 · 10 comments

Comments

@stuxcrystal
Copy link
Contributor

If PublicActivity can't connect to a MySQL Database, it will fail with the following error:

NameError: uninitialized constant PG
  /home/deploy/webapps/WEBAPP/shared/bundle/ruby/2.3.0/gems/public_activity-1.6.3/lib/public_activity/orm/active_record/activity.rb:38:in `rescue in <class:Activity>'
  /home/deploy/webapps/WEBAPP/shared/bundle/ruby/2.3.0/gems/public_activity-1.6.3/lib/public_activity/orm/active_record/activity.rb:30:in `<class:Activity>'
  /home/deploy/webapps/WEBAPP/shared/bundle/ruby/2.3.0/gems/public_activity-1.6.3/lib/public_activity/orm/active_record/activity.rb:6:in `<module:ActiveRecord>'
  /home/deploy/webapps/WEBAPP/shared/bundle/ruby/2.3.0/gems/public_activity-1.6.3/lib/public_activity/orm/active_record/activity.rb:3:in `<module:ORM>'
  /home/deploy/webapps/WEBAPP/shared/bundle/ruby/2.3.0/gems/public_activity-1.6.3/lib/public_activity/orm/active_record/activity.rb:2:in `<module:PublicActivity>'
  /home/deploy/webapps/WEBAPP/shared/bundle/ruby/2.3.0/gems/public_activity-1.6.3/lib/public_activity/orm/active_record/activity.rb:1:in `<top (required)>'
  /home/deploy/webapps/WEBAPP/shared/bundle/ruby/2.3.0/gems/public_activity-1.6.3/lib/public_activity/orm/active_record.rb:2:in `require_relative'
  /home/deploy/webapps/WEBAPP/shared/bundle/ruby/2.3.0/gems/public_activity-1.6.3/lib/public_activity/orm/active_record.rb:2:in `<top (required)>'
  /home/deploy/webapps/WEBAPP/shared/bundle/ruby/2.3.0/gems/public_activity-1.6.3/lib/public_activity.rb:51:in `inherit_orm'
  /home/deploy/webapps/WEBAPP/shared/bundle/ruby/2.3.0/gems/public_activity-1.6.3/lib/public_activity/models/trackable.rb:6:in `included'
  /home/deploy/webapps/WEBAPP/shared/bundle/ruby/2.3.0/gems/public_activity-1.6.3/lib/public_activity/common.rb:25:in `include'
  /home/deploy/webapps/WEBAPP/shared/bundle/ruby/2.3.0/gems/public_activity-1.6.3/lib/public_activity/common.rb:25:in `block in <module:Common>'

We are using Rails 4.2.11 with Public Activity 1.6.3.
It links to this file https://github.com/chaps-io/public_activity/blob/2c56992a61a1a6deaca92a66f7031e83a05c4e9a/lib/public_activity/orm/active_record/activity.rb#L40

@pokonski
Copy link
Member

pokonski commented Mar 5, 2019

Can you share your PublicActivity config? The one you probably have in initializers

@stuxcrystal
Copy link
Contributor Author

stuxcrystal commented Mar 5, 2019

I just checked, we do not have an initializer for PublicActivity. We are running ActiveRecord.

It looks to me that the actual error can't propagate out of the function as the uninitialized constant error is shadowing the actual error.

@pokonski
Copy link
Member

pokonski commented Mar 5, 2019

Mmm good catch, PG will not exist if the app is not using pg gem. This would probably need creating dummy PG constant and its exception when pg is not loaded.

@stuxcrystal
Copy link
Contributor Author

You also need to do that with Mysql2::Error::ConnectionError two lines below as not all apps may use Mysql.

@ashokmiryal
Copy link

does it supports mongoid? I am getting uninitialized constant PG error

@zainonrails
Copy link

When would this merged in master branch..?

@pokonski
Copy link
Member

pokonski commented Sep 30, 2019

@zainonrails this has been released as 1.6.4. Can you try?

I don't merge to master, I use separate branches for each stable version.

@pokonski
Copy link
Member

@ashokmiryal it doesn't. Please post the exception you are getting or submit a PR which adds a clause for Mongoid exception in a similar way to how PG/Mysql are handled: 83d1406

@zainonrails
Copy link

So upgrading the gem would also solve this as right now i am using 1.6.3 branch in my gemfile.

@pokonski
Copy link
Member

pokonski commented Oct 1, 2019

@zainonrails then upgrade to 1.6.4. It's released :) Unless I missunderstood you.

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

4 participants