Find file
Fetching contributors…
Cannot retrieve contributors at this time
48 lines (27 sloc) 974 Bytes

Acts As Favable

Allows for favorite refer to be added to multiple and different models.


Install(on Rails3)

To install as a plugin

rails plugin install

To install as a gem

sudo gem install acts_as_favable

Generate your favorite model:

rails generate favorite

Then migrate your database:

rake db:migrate


Make your ActiveRecord model act as favable.

class Model < ActiveRecord::Base

mark a favorite flag to a model instance

favable = Model.create
favable.favorites.create(:note => "I like this and will make it one of my favorites")

Fetch favorites for a favable model:

favable = Model.find(1)
favorites = favable.favorites.recent.limit(10).all

Attention: This plugin/gem is heavily influenced by Acts As Taggable and almost copied from acts_at_commentable.


Blog post..