-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Discuss] Extending Doorkeeper & working with Zeitwerk #1211
Comments
Hi @jasl . Well, what is the problem with something like: # config/initializers/doorkeeper.rb
Doorkeeper.configure do
# ...
end
Doorkeeper::Application.prepend(MyCustomizations)
# lib/mny_customizations.rb
module MyCustomizations
extend ActiveSupport::Concern
included do
validates :icon_path, :help_url, presence: true # don't forget to replace default views
def icon
# ...
end
end
end ? It plays nice with lazy loading and so on. Or you wanna to have an ability to configure it somehow using Doorkeeper configuration? Also could you please provide more info on issue with Zeitwerk? Don't see any reasons to not to work with it 😕 |
Unfortunately,
without To let |
Well, it was just an idea. You can use any other methods to extend the model, like |
Our ORM-specifics models don't follow path convention of Zeitwerk, and after I read doc & did research, I give up to hacking Zeitwerk, too complicated. Instead, there is a simpler way, wrapping I tested roughly and it works, but didn't know if it has any side effect. I will keep watching on this. But I'm thinking what about we allow configure |
You are talking about this long-term existing in gem code, right? doorkeeper/lib/doorkeeper/orm/active_record.rb Lines 33 to 35 in 7242515
We already uses hooks for AR, Sequel and Mongoid/MongoMapper, read #913 |
I think we can achieve this by creating |
No, I mean before Rails 6.0.0.beta2 we don't need to wrap the override in |
Sound good to me, I will do this later, could you accept this to Doorkeeper-gem organization and publish it? I think I don't have enough time to maintain gems, but if something breaks, I will attach PR. |
Whatever I use |
There's a technique about extending engine's models
https://edgeguides.rubyonrails.org/engines.html#overriding-models-and-controllers
It works well in Rails 5, but break in Rails 6, I guess it relates to our lazy constructing models
to support different ORMs (this was introduced by me).
Extending Doorkeeper's models is useful, for example, I want to add some description fields such as icon, website to doorkeeper's application model.
I want to find a way to extending doorkeeper's models, I think I can ensure not break user side, but I'm not sure not to break Doorkeeper's extensions, is this acceptable? any suggestion?
The text was updated successfully, but these errors were encountered: