0.0
No commit activity in last 3 years
No release in over 3 years
Like Dislike/Unlike by user by any object resource, dependency of act_as_votable
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

LikeDislike (Like or UnLike)

Like Dislike is a Ruby gem it provides facebook or youtube kind of like and dislike functionality with both frontend and backend features.

It works with the dependency of acts_as_votable gem for more details acts_as_votable

##Setup

Gem Installation

Add this line to your application's Gemfile:

gem 'like_dislike'

And then execute:

$ bundle

Database Migration

Create migration for Votes polymorphic table for vote entries for all the resource

  rails g like_dislike:migration

For Caching and finding the vote counts easily, vote counts can be maintained on the resource level run this.

rails g like_dislike:migration TableName

eg:

rails g like_dislike:migration Post
rails g like_dislike:migration Comment

Finally run:

rake db:migrate

##Usage

Add below code in you Votable Model reesource.

acts_as_votable

For eg:

class Comment < ActiveRecord::Base
  acts_as_votable
end

Add below code in your Voter Resource Model resource.

acts_as_voter

For eg:

class User < ActiveRecord::Base
  acts_as_voter
end

require the file in javascript and stylesheet in application:

#in application.js
//= require like_dislike
#in application.css
*= require like_dislike

Here the ultimate things comes, add this line wherever you want like and dislike button want to enable with resource:

<%= like_unlike_button(resource) %>

For eg:

#bookmark is the object
<%= like_unlike_button(bookmark) %>  

Contributing

  1. Fork it ( https://github.com/[my-github-username]/like_dislike/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