Subscribable
This is a basic gem that allows different models to subscribe/follow each other.
This gem is supported by American Honors. (http://americanhonors.org)
Example: A model instance can subscribe to another model instance
person = Person.new
group = Group.new
person.subscribe_to!(group)
Now your person has a collection of subscriptions that includes a group.
person.subscriptions #=> [group]
What you do with this is up to you. You could create some sort of activity feed based on subscriptions.
Some additional helper methods:
person.subscribed_to?(group) #=> true
group.person_subscribers #=> [group]
person.delete_subscription_to!(group)
Installation
Add this line to your application's Gemfile:
gem 'subscribable'
And then execute:
$ bundle
Or install it yourself as:
$ gem install subscribable
In your terminal run:
rails g subscribable:sub_relation
Then make sure you run your migration:
rake db:migrate
In order to make a model subscribable you need this code in your model:
include Subscribable::RelationAssigner
subscribable
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request