Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Social Media Sharing Buttons Gem for Ruby on Rails

I am trying to find a good gem that will allow me to add social media sharing buttons to my Rails 3 app (similar to the Wordpress plugins AddThis). The key sites that I want to enable sharing with are Facebook, Twitter, LinkedIn, and Google+. I want to allow two levels of sharing i.e. the ability to share a link to the site as a whole and the ability to share specific pages or posts on the site. Thanks in advance!

What gems would you recommend?

like image 986
Spencer Avatar asked Aug 19 '11 16:08

Spencer


5 Answers

Install

In your Gemfile:

gem 'social-share-button'

And install it:

$ bundle install

$ rails generate social_share_button:install

Configure

here https://github.com/huacnlee/social-share-button

like image 56
rails_id Avatar answered Nov 17 '22 23:11

rails_id


As you shop for these widgets you should not think in terms of Rails solutions but Javascript solutions. Since Rails had adopted JQuery as it default JS framework you can also look in that direction.

Here are a few: http://plugins.jquery.com/?s=social

I recommend shareBox

like image 42
allesklar Avatar answered Nov 17 '22 23:11

allesklar


I found shareable to be pretty good.

like image 23
DickieBoy Avatar answered Nov 18 '22 01:11

DickieBoy


Haucnlee's gem unfortunately doesn't support counters (currently), but I was able to use https://github.com/iffyuva/social-buttons to implement this for myself. See for a rails 3 gem for sharing content on social media sites in one click walkthrough.

like image 42
zrisher Avatar answered Nov 18 '22 01:11

zrisher


Sharing to Facebook

http://www.facebook.com/dialog/feed?app_id=123456789&link=http://Domain_name/<%= @post.id %>/<%= @post.name %>&picture=<%= @default_image_of_the_post.image_url %>&name=<%= @post.title %>&caption=<%= @post.caption %>&description=<%= @post.description %>&redirect_uri=http://Domain_name/<%= request.original_url %>&display=popup” target=’_blank’>

Note:

app_id = ‘App_Id’ which is given by facebook. U need to register your app in Facebook

check here ‘https://developers.facebook.com‘ go to Apps tab and click on ‘Create a New

App’

link = This is the link for this particular post, if any user clicks on this post in FB, he will be

redirected to this link

picture = Picture for the post

name = Title of the post

caption = Caption for the post

description = Description for the post

redirect_uri = after posting, To which link u want user to be redirected. Its better to give ‘request.original_url’, user will redirect to same page from where he has been sharing the link


Sharing to Linked in

http://www.linkedin.com/shareArticle?mini=true&url=http://Domain_name/<%= @post.id %>/<%= @post.name %>&title=<%= @post.title %>&summary=<%= @post. description %>” target=”_blank”>

Note:

url = This is the link for this particular post, if any user clicks on this post in Linked in, he will be

redirected to this link

Title = Title for the post

summary = Description for the post

like image 1
Akshay Avatar answered Nov 18 '22 01:11

Akshay