Make your Ruby objects Likeable with Redis
The Gowalla development team has released Likeable, a Ruby library to make it simple to add social ‘likes’ to your Ruby classes.
With just a few lines of Ruby, you can track likes using Redis as your data store:
class Comment
include Likeable
# ...
end
class User
include Likeable::UserMethods
# ...
end
comment = Comment.find(15)
comment.like_count # => 0
current_user.like!(comment) # => #<Likeable::Like ... >
comment.like_count # => 1
comment.likes # => [#<Likeable::Like ... >]
comment.likes.last.user # => #<User ... >
comment.likes.last.created_at # => Wed Jul 27 19:34:32 -0500 2011
Richard Schneeman walks through an example in this screencast:
Check out the announcement or GitHub repo for more.
Discussion
Sign in or Join to comment or subscribe