Skip to content

Instantly share code, notes, and snippets.

@cgallagher
Created June 11, 2012 10:05
Show Gist options
  • Save cgallagher/2909405 to your computer and use it in GitHub Desktop.
Save cgallagher/2909405 to your computer and use it in GitHub Desktop.
OG Endpoint
def show
if request.user_agent.index('facebookexternalhit')
@thing = Thing.find(params[:id])
add_meta :property => 'og:title', :content => @thing.title
add_meta :property => 'og:type', :content => "article"
add_meta :property => 'og:url', :content => @thing.url_to_the_content
add_meta {{:property => 'og:image', :content => @thing.image_url}}
end
end
@cgallagher
Copy link
Author

Need to install the metatags gem as a part of your bundle:

gem "metatags", "0.1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment