Skip to content
A simple plugin that allows a user to mark anything as 'read.' Common usage would include forum posts, news items, etc.
Ruby
Pull request Compare This branch is 2 commits ahead of mbleigh:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
generators/acts_as_readable_migration
lib
rails
README
acts-as-readable.gemspec
init.rb

README

ActsAsReadable
==============

ActsAsReadable allows you to create a generic relationship of items which can
be marked as 'read' by users. This is useful for forums or any other kind of
situation where you might need to know whether or not a user has seen a particular
model.

Installation
============

To install the plugin from git:

script/plugin install git://github.com/jcnetdev/acts-as-readable.git

To install the plugin from a gem, add this to our environment.rb:

config.gem 'jcnetdev-acts-as-readable', :version => '>= 1.0',
                                        :lib => 'acts_as_readable',
                                        :source => 'http://gems.github.com'


You will need the readings table to use this plugin. A generator has been included,
simply type

script/generate acts_as_readable_migration

to get the standard migration created for you.

Example
=======

class Post < ActiveRecord::Base
  acts_as_readable
end

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>]

Copyright (c) 2008 Michael Bleigh and Intridea, Inc. released under the MIT license
Something went wrong with that request. Please try again.