Overriding model in gem, adding callback and methods

前端 未结 1 1213
小鲜肉
小鲜肉 2021-01-05 18:18

I\'ve installed the ActiveRecord Reputation System on my app. How would I go about overriding or adding a callback/method to Evaluation model?

In gener

相关标签:
1条回答
  • 2021-01-05 19:19

    Simply reopen the class:

    module ReputationSystem
      class Evaluation < ActiveRecord::Base
        def my_method_here
          puts "Yey!"
         end
       end
    end
    

    You can put this file in config/initializers/my_monkey_patch.rb or in lib/my_monkey_patch.rb, but the later must be loaded into your code.

    0 讨论(0)
提交回复
热议问题