Skip to content

kishore-mohan/like_dislike

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Like Dislike/Unlike Gem with button and ajax

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •