
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
This gem will add an easy-to-use Facebook Share button feature to your Rails project. This gem does not take care of authentication or authorization. It's only purpose is to bind Facebook Share button to anything you want.
Any public method will return just JavaScript code and nothing else.
gem install facebook_share
This gem supports jQuery and Dojo, be sure to have it installed in your project.
In case of jQuery, the gem does not depend on jquery-rails, because some projects use jQuery without it or expose jQuery function to another global variable or use jQuery.noConflict.
Further information about choosing framework are described in next section.
If you don't have a Facebook Application for your project yet, create one.
Then add this to your ApplicationHelper
module ApplicationHelper
include FacebookShare
end
Global configuration (config/initializers/facebook_share.rb ):
FacebookShare.default_facebook_share_options = {
:framework => :jquery,
:jquery_function => "$",
:app_id => "YOUR_APP_ID",
:status => "false",
:cookie => "false",
:xfbml => "false",
:selector => '.fb_share',
:locale => "en_US"
}
You can ommit app_id parameter, if you already have a Facebook Application initialized in your project.
Be sure you have
in your application layout before you load the Facebook Connect JSDefault facebook Share options can be changed with the above code snippet. The options can be also passed to any public method, so you don't have to rely on defaults at any given time.
app_id, status, cookie, xfbml, locale, selector, and the various FB.ui parameters also have _js variants which insert Javascript to calculate the value at runtime. These Javascript snippets must be expressions, not full statements. If a _js option is present, the non-_js version of the option is ignored.
The simplest usage (given you specified your project's Facebook Application ID) is as follows:
<%= link_to 'Share on Facebook', '#', :class => "fb_share" %>
<%= facebook_share_once %>
That will produce a link "Share on Facebook" with a class of "fb_share" and a corresponding JavaScript script tags initializing Facebook app and sharing method bind to click on that link. By default gem passes ".fb_share" selector to the Javascript framework of your choice.
You can find more usage examples at Railslove blogpost about this gem.
v0.0.6
v0.0.5
v0.0.4
v0.0.3
v0.0.2
v0.0.1
Copyright (c) 2011 Mike Połtyn. Originally build as part of work at Railslove.
The MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.