Monkey patching Devise (or any Rails gem)

后端 未结 7 1391
甜味超标
甜味超标 2020-12-07 23:11

I\'m using the Devise authentication gem in my Rails project, and I want to change the keys it\'s using in flash alerts. (Devise uses :notice and :alert flash keys, but I wa

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 23:32

    I know this is an old thread but this might still be helpful. You should be able to require the file from the gem directory using the engine called_from path.

      require File.expand_path('../../app/helpers/devise_helper',Devise::Engine.called_from)
      require File.expand_path('../../app/controllers/devise_controller',Devise::Engine.called_from)
    
      DeviseController.class_eval do
        # Your new methods here
      end
    

提交回复
热议问题