Re-open an ActiveRecord model that's provided by a gem

后端 未结 6 1965
旧时难觅i
旧时难觅i 2021-02-10 05:53

I\'m trying to extend an ActiveRecord model (Vote) that a gem (https://github.com/peteonrails/vote_fu) provides to my application. (I.e., there is no vote.rb<

6条回答
  •  生来不讨喜
    2021-02-10 06:33

    could you try something like this :

    class Vote
        after_create :create_activity_stream_event
        has_one :activity_stream_event
    
        def create_activity_stream_event
            # something..
        end
    end
    

    I think than it will add your function and call functions "after_create" and "has_hone".

提交回复
热议问题