Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7671469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:03:54+00:00 2026-05-31T16:03:54+00:00

I want to render for facebook bot special data. I have og.html.erb <!DOCTYPE html><html><head>

  • 0

I want to render for facebook bot special data. I have og.html.erb

<!DOCTYPE html><html><head>
<meta property="og:title" content="<%= @og[:title] %>">
<meta property="og:type" content="website">
<meta property="og:url" content="<%= @og[:url] %>">
<meta property="og:description" content="<%= @og[:description] %>">
<meta property="fb:admins" content="100000235955045">
</head><body></body></html>

And this in my page controller:

# encoding: UTF-8
class PageController < ApplicationController
  def index
    @og = { :title => 'index title', :description => 'index desc', :url => 'http://someurl.com/index' }
    if request.headers['HTTP_USER_AGENT'].eql? 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)'
      render '/og', :layout => false
    end
  end

  def cv
    @og = { :title => 'cv title', :description => 'cv description', :url => 'http://someurl.com/cv/' }
    if request.headers['HTTP_USER_AGENT'].eql? 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)'
      render '/og', :layout => false
    end
  end
end

How i can to DRY it? Am i need use helper or before_filter?
If i will user before_filter, how i can set @og hash from my controller?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:03:55+00:00Added an answer on May 31, 2026 at 4:03 pm

    I think you can define a method in ApplicationController like this,

    def render_og
      if request.headers['HTTP_USER_AGENT'].eql? 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)'
        render '/og', :layout => false
      end
    end
    

    then your page controller becomes this,

    # encoding: UTF-8
    class PageController < ApplicationController
      def index
        @og = { :title => 'index title', :description => 'index desc', :url => 'http://someurl.com/index' }
        render_og
      end
    
      def cv
        @og = { :title => 'cv title', :description => 'cv description', :url => 'http://someurl.com/cv/' }
        render_og
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to render a page in grails without a <html> , <head> and
i want to render one of these sets of views: head body-$id1 foot OR
I have a 3rd party ActiveX control I want to render within other presentation
If I have an object say @user and I want to render only certain
I have a directory structure of directories and files that I want to render
I want to render an ERDAS-Image-file (suffix .img) with the UMN-Mapserver. The data is
I want to render tiles to the screen from a text file. I have
I have a question about DealSpot. As the Facebook API Doc suggests, I want
Basically I have a set of object values I want render in 2 separate
I want to render equations to PNG files and embed them in the HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.