Gem usage unread with public_activity

I'm not sure if this is possible, but given how you can introduce a method into modules, is there a way to insert "act_as_readable: on =>: update_at" in PublicActivity :: Activity?

The problem is this: I want the unread ones to also keep track of new actions that the user has not yet seen, so I first tried this this way.

class Activity < PublicActivity::Activity
  acts_as_readable :on => :updated_at
end

class User < ActiveRecord::Base
  acts_as_reader
end

However, I noticed in the record (DB table read tables) when I do

Activity.mark_as_read! :all, :for => current_user

that the readable_type key is set to "PublicActivity :: Activity" instead of "Activity"

This is because Unread Gem uses

user.read_marks.build(:readable_id => obj.id, :readable_type => self.base_class.name)

what base_class gives the class closest to ActiveRecord :: Base What would be the best option?

1) - "act_as_readable: on = > : updated_at" PublicActivity:: Activity

2) fork PublicActivity , gem, "act_as..."

3) ... , , , , - , PublicActivity!

: (DB table read_marks) PublicActivity:: Activity, Activity,

Activity.unread_by(current_user).count

.

PublicActivity::Activity.unread...

, "act_as_readable: on = > : updated_at" Activity, PublicActivity:: Activity.

Public_Activity "monkey-patch", , , - , . . readable_type - PublicActivity:: Activity, ,

PublicActivity::Activity.mark_as_read! :all, :for => current_user


# config/initializers/activity_unread.rb
PublicActivity::Activity.module_eval do

  acts_as_readable :on => :updated_at

end

! readable_type 20, . , .

+5
3

REKO

, , ( Ruby 1.9.3 Rails 3.2),

PublicActivity:: Activity.template = YAML.load_file ( "# {RAILS_ROOT}/config/pba.yml" )

PublicActivity:: Activity.template = YAML.load_file ( "# {Rails.root}/config/pba.yml" )

pba_setup . , , ? , !

+2

: , public_activity, PublicActivities.

, , ( "publicactivity.visit" ) .

+1

, ,

<span class='badge'> 
    <%=  PublicActivity::Activity.order("created_at desc").where(owner_id: current_user.follower_ids , owner_type: "User").count %>
</span>
0
source

All Articles