Reputation: 104079
A plugin provides a model called User
. Is it possible to reopen it in my app?
If I create app/models/user.rb
and try it there, the whole model is overridden and the original plugin methods are no longer available.
Upvotes: 1
Views: 163
Reputation: 104079
This is the only way I found so far:
# app/models/plugin_user.rb
class PluginUser
def self.load
User.class_eval do
# my code here
end
end
end
# plugin model:
class User
# ...
end
PluginUser.load
It would be nice if there was a way of doing this without modifying the plugin code. In this case it doesn't matter because the plugin is mine, but if I needed to do the same to another plugin I'd need to fork it.
Upvotes: 1