Code Monkey home page Code Monkey logo

acts-as-readable's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.