Giter Site home page Giter Site logo

shiningray / acts_as_favorite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from netmaniac/acts_as_favorite

0.0 2.0 0.0 110 KB

git(hub) mirror of webwideconsulting.com's acts_as_favorite plugin

Home Page: http://svn.webwideconsulting.com/plugins/acts_as_favorite/

License: MIT License

Ruby 100.00%

acts_as_favorite's Introduction

= ActsAsFavorite

http://svn.webwideconsulting.com/svn/acts_as_favorite

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:
current_user.has_favorite(Blog.find(43))

To Test(returns true/false):
current_user.has_favorite?(Blog.find(99))
current_user.has_favorite_venues?

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

acts_as_favorite's People

Contributors

joergbattermann avatar shiningray avatar

Watchers

 avatar  avatar

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.