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

mysql2 adapter not loaded when railtie runs #62

Open
ak47 opened this issue Apr 27, 2015 · 3 comments
Open

mysql2 adapter not loaded when railtie runs #62

ak47 opened this issue Apr 27, 2015 · 3 comments

Comments

@ak47
Copy link

ak47 commented Apr 27, 2015

I have a new Rails 4.2.1 app, followed usual Readme setup with Gemfile and placed "include ActiveUUID::UUID" line in my model. However, every time I run specs or rails console, the activeuuid patches have not been applied.

I added a break to the .apply method in ActiveUUID::Patches, and the mysql2 adapter,
ActiveRecord::ConnectionAdapters::Mysql2Adapter
is not defined at that point.

The result, if I start a console, is that I need to do a manual "ActiveUUID::Patches.apply!" to get things working.

Anybody else see this? Am I doing something wrong?

Odd part is, I have a Rails 4.2.0 app using activeuuid and all is good.

@ak47
Copy link
Author

ak47 commented Apr 27, 2015

sort of solved the problem with a bit of hackery,

adding an initializer with:

ActiveRecord::Base.connection

Forces AR to load and the railtie works as designed.
Maybe this is just a dev/test env thing - not sure yet.

@timbogit
Copy link

timbogit commented May 3, 2015

I am seeing the exact same problem with a Rails 4.2.1 application in development environment.
I have added a migration to add a uuid column, and the migration fails because the previous run of ActiveUUID::Patches.apply! did not patch the respective classes, due to ActiveRecord::ConnectionAdapters::Mysql2Adapter not being defined.

@timbogit
Copy link

timbogit commented May 3, 2015

For what it's worth:
Adding a simple ActiveRecord::Base, to initiate ActiveRecord class loading, before this line solves the issue for me in Rails 4.2.1.

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

2 participants