Create a 'Like' or '+1' button with make_flaggable

Charles Wood · 4K views · 2011 · 23:07

Open on YouTube

Python, Ruby & scripting languagesWeb developmenttutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it when implementing like, favorite or voting features in Rails with the make_flaggable gem, both as a tutorial to follow and as the source of their setup.

Recommended by 2 people across 2 different months, 2012 to 2014.

What it is

A 23-minute Rails screencast from 2011 by Charles Wood showing how to build a Like or +1 button in a Rails app using the make_flaggable gem. It walks through a simple app and the flagging concept step by step.

What people said

Recommends bholtbholt · 2013-11 · Stack Overflow · on “Update Ruby on Rails partial with Ajax”

I've built a fav icon that works like a Facebook like/unlike button, and I'm trying to update it via Ajax but can't seem to get it working. I think I'm missing something simple. events_controller.rb def fav @event = Event.find(params[:id]) current_user.toggle_flag(@event, :fav) #events_helper.rb respond_to do |format| format.js end end events_helper.rb def toggle_fav(event, user) if user_signed_in? #change icon from heart to empty heart and vice-versa link_to user.flagged?(event, :fav) ? #if the event is flagged content_tag(:span, " ", :class => "glyphicon glyphicon-heart") : #show full heart content_tag(:span, " ", :class => "glyphicon glyphicon-heart-empty"), #else show empty heart fav_eve

Recommends Dylan Richards · 2013-12 · Stack Overflow · on “Simple voting system in rails”

[this video] Video I used to implement mine. If you need to display the total number of votes, then just run vote.count or vote.size .

Cites Jide · 2012-05 · Stack Overflow · on “gem make_flaggable”

I am currently working on implementing a like button, following the tutorial on [this video] , which says i should install gem 'make_flaggable', :git => 'git://github.com/cavneb/make_flaggable.git', when enter this in my gem file and run 'bundle install' i get the error below, i then run bundle update and i get another error. Any ideas on how to resolve this? Thanks Bundler could not find compatible versions for gem "activerecord": In Gemfile: make_flaggable (>= 0) ruby depends on activerecord (~> 3.0.0) ruby rails (= 3.2.1) ruby depends on activerecord (3.2.1)

Cites Mathieu James Baruch Robertfor · 2014-05 · Stack Overflow · on “No column "flaggings_count" using make_flaggable with Rails 4”

I'm working on a Rails 4 app, and installed the make_flaggable gem (following this video tutorial [this video] ) to allow users to like posts. Whenever I try to make a user like a post (on the browser or console), it keeps showing me this error : SQLite3::SQLException: no such column: flaggings_count: UPDATE "posts" SET "flaggings_count" = COALESCE("flaggings_count", 0) + 1 WHERE "posts"."id" = 67 Here's my like method : def like @post = Post.find(params[:id]) current_user.flag(@post, :like) redirect_to posts_path, :notice => "You now like this post" end The migration looks ok, did it happen to anyone? Thanks in advance!