I am using metamagic gem to create meta tags for facebook.
I have this in my rails app.
<%
meta og: {
title: "Mywebsite.com - " + @micropost.user.name,
type: "article",
description: ActionView::Base.full_sanitizer.sanitize(@micropost.content)
}
%>
I am trying to add url and image property.
<%
meta og: {
title: "Mywebsite.com - " + @micropost.user.name,
type: "article",
description: ActionView::Base.full_sanitizer.sanitize(@micropost.content)
url:
image:
}
%>
I want the url and image to be taken from the following.
https://www.mywebsite.com/microposts/<%= @micropost.id %>
<%= image_tag @micropost.user.avatar.url(:preview), :style => "display: none;" %>
But I always get errors. When I don't get errors, I get only
/micropost/15
/image/1/something.png
How do I the supply the complete values? Like
https://www.mywebsite.com/microposst/15
https://www.mywebsite.com/image/1/something.png
I tried double qoutes and single qoutes. But nothing seems to work.
Kindly help.
Try this,
<% img = "<img src="+ micropost.user.avatar.url(:preview) +" style='display: none;'>" %>
<%
meta og: {
title: "Mywebsite.com - " + @micropost.user.name,
type: "article",
description: ActionView::Base.full_sanitizer.sanitize(@micropost.content),
url: "https://www.mywebsite.com/microposts/" + @micropost.id.to_s,
image: img.html_safe
}
%>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.