0

I have a view page which has an embedded youtube video on it. I have the proper OG tags so that the video is embedded on facebook when shared.

But in order for above to work, I need to programatically hit the Facebook debugger endpoint so that my url gets cached.

I've created an after_create on my Movie model:

after_create :facebook_cache

def facebook_cache
    FacebookCacheUrl.call(Rails.application.routes.url_helpers.movie_url(self))
end

The issue that I'm encountering is that my app is sending Facebook the friendly url, e.g. www.mysite.com/movies/friendly-movie-title. But at the time the app sends the url, the page is showing a 404. So Facebook is caching the server error page info.

Later in the lifecycle, the url works properly.

My question is where should I be pinging the Facebook debugger so that it happens as soon as possible without leading to a 404?

Jackson Cunningham
  • 4,973
  • 3
  • 30
  • 80
  • _“My question is where should I be pinging the Facebook debugger so that it happens as soon as possible without leading to a 404?”_ – as soon as your system _doesn’t_ respond with a 404 for that URL any more …? It is your system, so you should know best when that is, right? – CBroe Mar 24 '16 at 09:06
  • Well that's why I'm asking. It's Rails. I thought an after_create callback would be after the URL has been generated. But it's not, so I'm asking... – Jackson Cunningham Mar 24 '16 at 17:23

0 Answers0