Skip to content
This repository has been archived by the owner on Dec 12, 2018. It is now read-only.

controlshift/facebook_share_widget_rails

Repository files navigation

Facebook Share Widget - Rails Plugin

Build Status

This project rocks.

Installation

Add the gem to your Gemfile

gem 'facebook_share_widget', :git => 'https://github.com/controlshift/facebook_share_widget_rails.git'

The widget requires Facebook access token to work and the token could be provided in 2 ways:

Facebook JS SDK integration

Create an initializer in your own application and set the Facebook App ID and secret. The widget will then obtain the access token from the cookies automatically.

FacebookShareWidget.client_id = "client_id"
FacebookShareWidget.client_secret = "client_secret"

Manually specifying token in session

Create an initializer in your own application and set the session key that contains the access token. The widget will then obtain the access token from the session.

FacebookShareWidget.access_token_session_key = :facebook_access_token

Usage

Mount the plugin in routes.rb

mount FacebookShareWidget::Engine => "/widget"

On the page that embeds the widget

Add javascript and stylesheet to the head

= stylesheet_link_tag "facebook_share_widget/application"
= javascript_include_tag "facebook_share_widget/application"

Render the widget in the body

= render "/facebook_share_widget/facebook/widget"