= Follow feature for Rails3 with Mongoid == Installation In Gemfile: gem 'mongoid_follow' == Legend (to ease complications) "follower" is a model who follows "followee" is a model who would be followed == To use To make mongoid_follow usable you need to include Mongoid::Followee into your document who would be followed then you also need to include Mongoid::Follower in your follower model: class User include Mongoid::Document include Mongoid::Followee include Mongoid::Follower end class Group include Mongoid::Document include Mongoid::Followee end You can then follow a model using: @bonnie = User.create @clyde = User.create @bonnie.follow(@clyde) @bonnie.unfollow(@clyde) You can also see whether a model is a follower of another model or if a model is a followee of another model: @clyde.follower?(@bonnie) @bonnie.followee?(@clyde) You can also be a follower of other models @gang = Group.create @bonnie.follow(@group) @gang.follower?(@bonnie) @bonnie.follows?(@gang) == Callbacks You can attach callbacks to the follower/followee models before or after the follow. # Follower model def before_follow(followee) puts 'Notify me' end # Other follower callbacks after_follow before_unfollow after_unfollow # Followee model def before_followed_by(follower) puts 'Something here' end # Other followee callbacks after_followed_by before_unfollowed_by after_unfollowed_by * Note: careful with using callbacks, we have no transaction so if breaks on your callbacks, what gets saved is saved. * Any bug or issue, please send me an email to aeguintu@gmail.com == For development gem install 'mongoid' gem install 'bson_ext' gem install 'database_cleaner' gem install 'rspec' rake spec/specs/follow_spec_rb == TODO * finish up todo's (list of followers and followees) ==FINISHED * count of followers/followees ==FINISHED * common followers (or maybe followees) ==FINISHED == Thanks Super thanks: to mongoid_followable. to Tristan Peralta. == Copyright Copyright (c) Alec Guintu. See LICENSE.txt for further details.