how to set participant(type and id) for news feed entry in pfeed
hi i am using pfeed for generating news feed in my project. how can i set value of participant id and type while generating feed entry. i do not want to change plugin code.i need to change/(add some code) in model to achieve this functional开发者_JS百科ity
pfeed has an entry for participant id and type in pfeed_item tablefirst argument is participant for feed entry.this should be AR object...so passing current_user to as first argument to method(which generate) feed will set participant.
b=Book.find 2
b.checkout current_user
if checkout is registered for generating feed in pfeed then participant will be set but how to pass current user if we want to generate feed with AR base class methods like generate feed for book update
b.update_attribute :name,"new name"
one solution is to override or add new method for update which will registered to generate feed and this method calls base method..like
class Book <<AR::Base
def update user,...
self.update_attribute(s) ...
end
now add this method to generate feed in book class
emits_pfeeds :on=>[:update,...]
精彩评论