ajax - Rails Conditional Facebook OG Tags -


i have rails personality test app uses ajax render questions , show results.

i have been attempting share personality test results via facebook sending variable 1 of dashboard rails controller dynamically create tags.

however, variable nil when page first loaded (which causes error), fixed adding conditional (in application.html.erb):

<% if @cat %>    <meta property="og:title"         content="you got <%= @cat.name %>!"/>    <meta property="og:image"         content="<%= @cat.picture %>" />    <meta property="og:description"   content="<%= @cat.description%>" />    <meta property="og:url"           content="https://mysite" />    <meta property="fb:app_id"        content= "<%=env['facebook_app_id']%>" />    <meta property="og:type"          content="website"> <% end %> 

facebook not recognize tags when checked sharing debugger. tried initializing object (home controller):

def index   if params.has_key?("cat")     @cat = cat.find_by(name: params["cat"])   else     @cat = cat.find_by(name: "colonel meow")   end end 

with this, facebook not render new value, renders old value instead. put debugger in application.html make sure variables changing (they did). facebook did not refresh though.

is there way use conditional when assigning tags? or refresh tags facebook uses new variable?


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -