I'm using Intridea's Acts as Readable Rails plugin for a messaging system I'm currently building. I've defined my message class accordingly:
class Post < ActiveRecord::Base
acts-as-readable
end
And everything seems to be working according to plan, but when trying to execute to show unread messages in my message view, I'm running into problems.
Their example: (I've changed underscores to hyphens due to formatting issues)
bob = User.find_by_name("bob")
bob.readings # => []
Post.find_unread_by(bob) # => [<Post 1>,<Post 2>,<Post 3>...]
Post.find_read_by(bob) # => []
Post.find(1).read_by?(bob) # => false
Post.find(1).read_by!(bob) # => <Reading 1>
Post.find(1).read_by?(bob) # => true
Post.find(1).users_who_read # => [<User bob>]
Post.find_unread_by(bob) # => [<Post 2>,<Post 3>...]
Post.find_read_by(bob) # => [<Post 1>]
bob.readings # => [<Reading 1>]
So it seems as though if I wanted to list the number of unread messages sitting in a mailbox (for example Inbox (39) ), I should be able to do something like:
<%= Post.find_unread_by(current-user).count %>
But to no avail. I always seem to get stuck on the simple view issues after everything's set. Any ideas?