-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix Railtie and its require
s
#55
base: master
Are you sure you want to change the base?
Conversation
This pull request makes me realize that there are literally no tests which cover railtie… I'm opening a new issue #56 about that. |
lib/active_uuid/railtie.rb
Outdated
require "rails" | ||
|
||
module ActiveUUID | ||
class Railtie < Rails::Railtie | ||
railtie_name :activeuuid | ||
|
||
config.to_prepare do | ||
ActiveUUID::Patches.apply! | ||
ActiveUUID::ConnectionPatches.apply! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This very invocation concludes active_uuid/connection_patches.rb
, so I suppose moving line no. 2 here is a better option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By line no. 2, is that require "rails
or ActiveUUID::ConnectionPatches.apply!
or some other lines?
Where does the line need to be moved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have amended that commit. See: c4ffad2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevertheless, I'm not sure if we need Railtie at all. I don't like that it applies patches unconditionally. See my other comment: #55 (comment).
Codecov Report
@@ Coverage Diff @@
## master #55 +/- ##
=========================================
- Coverage 99.05% 98.86% -0.2%
=========================================
Files 21 23 +2
Lines 425 439 +14
=========================================
+ Hits 421 434 +13
- Misses 4 5 +1
Continue to review full report at Codecov.
|
One thing I've changed since original ActiveUUID is that monkey patching is now facultative (see README):
This pull request violates it, as loading the Railtie applies monkey patches unconditionally. I don't know… maybe we should remove this Railtie entirely? Or add some configuration option? Thoughts, @ribose-jeffreylau? I'll probably do some research. |
@skalee We see the following options:
We are OK either way. There may be other ways but these two are the most obvious that I can think of right now. |
@ribose-jeffreylau Will following satisfy your needs?
If the only purpose of this Railtie is to apply connection patches, then I'd rather like to remove it entirely, and encourage users to enable them explicitly if they want them. |
This works in Gemfile but not with gemspec inheritance. As long as we have documentation to indicate the user needs to write Or would something like this work? if defined?(Rails)
require "activeuuid/rails"
end |
No description provided.