2

I'm trying to implement a facebook like notification system in Rails using public activity and gem unread. I have installed the gem and created a public_activity.rb file in config/initializers. Code

PublicActivity::Activity.class_eval do
  acts_as_readable :on => :created_at
end

How do I create my views such that I can show the number of unread messages and also highlight these messages in my activities index.

My initial attempt at this looks like so

<%= PublicActivity::Activity.order("created_at desc").where(owner_id: current_user.following_ids , owner_type: "User").unread_by(current_user).count %> 

This gives me all notifications instead of just the unread ones. A Any ideas on how I can modify this?

Snake Sanders
  • 2,641
  • 2
  • 31
  • 42
Sawo Cliff
  • 2,888
  • 1
  • 17
  • 21

1 Answers1

0

By default, created_at is never empty. Just remove acts_as_readable :on => :created_at from your model. Default value is updated_at.

brcebn
  • 1,571
  • 1
  • 23
  • 46