Socialization is a Ruby Gem that allow any model to Follow and/or Like any other model. This is accomplished through a double polymorphic relationship on the Follow and Like models. But you don't need to know that since all the complexity is hidden from you.
Add the gem to the gemfile:
Run the generator:
rails generate socialization
This will generate two migration files and two models named Follow and Like. You may delete the Follow or Like model and migration if you don't need that functionality in your application.
I haven't tested it nor do I care much about Rails 2.3.x. Sorry!
Allow a model to be followed:
class Celebrity < ActiveRecord::Base ... acts_as_followable ... end
Allow a model to be a follower:
class User < ActiveRecord::Base ... acts_as_follower ... end
Allow a model to be liked:
class Movie < ActiveRecord::Base ... acts_as_likeable ... end
Allow a model to like:
class User < ActiveRecord::Base ... acts_as_liker ... end
Or a more complex case where users can like and follow each other:
class User < ActiveRecord::Base ... acts_as_follower acts_as_followable acts_as_liker acts_as_likeable ... end
Find out if an objects follows
Find out if an objects likes
Fork the project.
Make your feature addition or bug fix.
Add tests for it. This is important so I don't break it in a future version unintentionally.
Send me a pull request. Bonus points for topic branches.
acts_as_follower is a similar project that I only discovered when I was 95% finished writing the first version of Socialization. I initially intended to name this project acts_as_follower only to find out the name was taken. You might want to check it out as well so see which one suits your needs better. Socialization is simpler, supports “Likes” and easilly extendable; acts_as_follower has more “Follow” features.
Copyright © 2012 Carl Mercier – Released under the MIT license.