I am trying to use monkey controller plugin classes in a third-party gem. To be precise, I'm trying to add a wrapping parameter for controller development. In initializers/wrap_parameters.rbI added the following bit:
initializers/wrap_parameters.rb
Rails.application.config.after_initialize do DeviseController.class_eval do wrap_parameters :user, format: [:json] end end
It works great when the application starts, but when I change one of my controller classes, the parameter wrapper stops working immediately. As if the controller class was rebooted without the above patch.
How to make my monkey patch permanent?
thank
, monkeypatch, . , , , . - config/initializers:
module MyDeviseDecorator wrap_parameters :user, format: [:json] end class DeviseController < Devise.parent_controller.constantize extend MyDeviseDectorator end
, , monkeypatch. Im 100% , , ; , .