0.0
No commit activity in last 3 years
No release in over 3 years
An active record follow system developed using ruby on rails applying domain driven design and test driven development principles.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.2
~> 2.1
~> 13.0
~> 3.9
~> 1.4
~> 0.9

Runtime

>= 6.0, < 7.0
 Project Readme

FollowSystem

Build Status Gem Version Code Climate

An active record follow system developed using ruby on rails applying domain driven design and test driven development principles.

For rails 4 support use branch v0.0.7-stable.

For rails 5 support use branch v0.1.1-stable.

This gem is heavily influenced by cmer/socialization.

Installation

Add this line to your application's Gemfile:

gem 'follow_system'

And then execute:

$ bundle

Or install it yourself as:

$ gem install follow_system

Usage

Run the generator

$ rails g follow_system

Let's suppose for a moment that you have a celebrity news application and a User can follow a Celebrity or several Celebrity models. The user model becomes the follower and the celebrity model becomes the followee.

Celebrity object

class Celebrity < ActiveRecord::Base
  act_as_followee

  validates :name, { presence: true, uniqueness: true }
end

User object

class User < ActiveRecord::Base
  act_as_follower

  validates :username, { presence: true, uniqueness: true }
end

Followee object methods

celebrity.is_followee? # returns true

celebrity.followed_by?(user) # returns true if user follows the celebrity object, false otherwise

celebrity.followers_by(User) # returns a scope of FollowSystem::Follow join model that belongs to the celebrity object and belongs to follower objects of type User

Follower object methods

user.is_follower? # returns true

user.follow(celebrity) # Creates an instance of FollowSystem::Follow join model associating the user object and the celebrity object, returns true if succeded, false otherwise

user.unfollow(celebrity) # Destroys an instance of FollowSystem::Follow join model that associates the user object and the celebrity object, returns true if succeded, false otherwise

user.toggle_follow(celebrity) # Follows / unfollows the celebrity

user.follows?(celebrity) # returns true if the user object follows the celebrity object, false otherwise

user.followees_by(Celebrity) # returns a scope of FollowSystem::Follow join model that belongs to the user object and belongs to followee objects of type Celebrity

For more information read the api documentation.

Contributing

  1. Fork it ( https://github.com/pmviva/follow_system/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request