-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Use Spree::Base as models base class #3476
Use Spree::Base as models base class #3476
Conversation
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 is a good change, thanks 👏
But, I recommend to name not name this class ApplicationRecord
even though it is namespaced it potentially conflicts with the top level ApplicationRecord
new Rails apps have.
What about Spree::BaseRecord
? Also, we already have Spree::Base
, right? What do we do about it?
@tvdeyen Thank you for the quick review 🙇
I think that is important to keep |
36537fd
to
d68d514
Compare
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.
Thanks, @filippoliverani
@filippoliverani we discussed this PR during the last core team meeting. We think that probably it's enough to just use It has a different naming convention than what Rails users expect though but maybe changing the name of that class to We propose to keep the rest of the changes (using it for models that were inheriting from What do you think? |
Re-considered my approval as is after a core team discussion
@kennyadsl thank you for the update, the main point was to stop using |
Solidus ActiveRecord models should follow Rails 5+ convention of inheriting from an itermediate class to avoid monkey patching ActiveRecord::Base.
Monkey patching directly ActiveRecord::Base is dangerous and discouraged.
d68d514
to
8b5f2c2
Compare
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.
Thanks @filippoliverani!
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.
Hmm. I am not sure if Spree::Base is the correct base class for all our database models. They now all have Ransack and Preferences included.
Is this what we want? Does this lead to potential issues?
🤔
@tvdeyen |
@tvdeyen There's a lot of stuff coming along with |
Sorry, I wasn't so sure. Then it makes sense to use it for now. Next step could be to use a lean base class for models that do not need ransack and preferences. |
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.
👏
Description
Ref #3450
This PR introduces
Spree::ApplicationRecord
class and makes every ActiveRecord model previously inheriting fromActiveRecord::Base
inherit from it.To leverage the new hierarchy, an existing
Spree::Core::Permalinks
monkey patch onActiveRecord::Base
has been moved toSpree::ApplicationRecord
.This way Solidus is more compliant with Rails 5+ recommendations and the risk of unwanted side effects on
ActiveRecord::Base
is mitigated.Checklist: