Dear list, I am trying to override an after_save callback declared in main app using plugin. The main model class is:
class WorkHours < ActiveRecord::Base @after_save_call_back_called=0 after_save :after_save_call_back def after_save_call_back logger.debug "after save called" @after_save_call_back_called=1 end end And in my plugin (in the lib directory) : module WorkHoursPatch # cattr_accessor def self.included(base) # :nodoc: base.logger.debug "inlcuded called" base.extend(ClassMethods) base.send(:include, InstanceMethods) base.after_save.delete_if{ |callback| callback.method == :after_save_call_back } base.send(:after_save, :after_save_call_back_patched) end module ClassMethods end module InstanceMethods def after_save_call_back_patched logger.debug "overriden after save called" @after_save_call_back_called=1 end # Wraps the association to get the Deliverable subject. Needed for the # Query and filtering # def is_new # unless self.is_new.nil? # return self.is_new # end # return false; # end end end # ## Add module to Issue WorkHours.send(:include, WorkHoursPatch) The init.rb says require 'work_hours_patch' All this should work and running the console I an see the old plugin being deleted and the new one added. Please help! I am spending on this days! Evgeny -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.