Steve Koppelman
2006-Dec-08  17:15 UTC
AR callbacks on in-place editor, with a plugin model
[Apologies if this is a dupe. After the first attempt at posting it, 20
minutes passed, I replied to another thread, saw that reply and other
messages, but not this one. Watch all 2-3 copies show up an hour from
now.]
I''ve got a method I want to fire off whenever a model in a given AR
class is updated. However, it''s not happening, and there are two likely
culprits:
1. The updates are all made via the built-in in-place editors. They
update the data properly. Maybe the after_save callback isn''t made when
an in-place editor is involved.
2. The class itself is defined in a plugin, in this case
ActsAsCommentable, so maybe I''m just putting my callback declaration in
the wrong place. In this case, I''m putting it in my own module as
follows:
module CommentableExtensions
  module Juixe
    module Acts #:nodoc:
      module Commentable #:nodoc:
        module ClassMethods
          def acts_as_commentable
            include IdxFetcher
            after_update :update_idx
            serialize :feed
          end
          private
          def update_idx
            update_idx_feed(self)
            logger.info ''Called update_idx.''
          end
        end
      end
     end
    end
end
I know CommentableExtensions is loading because the serialize
declaration is working. However, I don''t think the callback is
triggering, because the message doesn''t get logged.
Should I be putting my callback somewhere else? How do I extend class
Comment, which is in the plugin, not in models/*? Or is this an issue
with callbacks and in_place_edit?
Thanks.
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---