Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (35 sloc) 1.69 KB
= ActsAsFavorite
This plugin provides a simple way to track users favorites within the system using
ActiveRecord models.
== Requirements
As we are not generating anything and there is no config, it is assumed in this version
that your user class is named "User", and you dont have an existing "Favorite" class.
== Installation and Configuration
1) Install as a plugin using script/plugin.
2) Generate the Favorite model, migrations, and tests with
./script/generate favorite_model Favorite
3) rake migrate to create the required tables
4) add <tt>acts_as_favorite_user</tt> to your User model
5) add <tt>acts_as_favorite</tt> to any models which you want to provide to users for favorites.
== The Specifics
Below are some specifics of using the plugin...
=== Setting and Using favorites
To Set:
To Test(returns true/false):
To Find:
current_user.all_favorites (all favorite referenced objects, blogs, etc)
current_user.favorite_blogs (metaprogramming references Blog entries only)
Blog.find(43).favoriting_users (returns users which have the specified blog set as a favorite)
=== Dynamic methods through the Identity mixin
The Identity mixin provides some dynamic methods for accessing favorite based information. You
can replace 'blahs' with any model class that acts_as_favorite.
user.has_favorite_blahs? --> returns true/false if the user has any favorites within the Blah class.
user.favorite_blahs --> returns an array of Blah's that are set as the users favorites.
== License
MIT License applies.
== Authors
Josh Martin