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

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -