开发者

how to set participant(type and id) for news feed entry in pfeed

开发者 https://www.devze.com 2023-03-01 03:29 出处:网络
hi i am using pfeed for generating news feed in my project. how can i set value ofparticipantid and type while generating feed entry.

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 table


first 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,...]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号