rails 的社交分享按钮 gem 出错
Error in Social-share-button gem with rails
我一直在尝试使用社交分享按钮 gem。请参阅下面的 link。 https://github.com/huacnlee/social-share-button
但问题是我不明白什么
<%= social_share_button_tag(@post.title) %>
意思是来自link。
我正在使用控制器 'Entry,' 所以我使用了
<%= social_share_button_tag(@Entry.title) %>
但是没有用。所以我刚刚做了
<%= social_share_button_tag("") %>
它确实有效,只是当我单击显示的按钮时,它不会转到 "share link."
希望我能从中得到一些理解!谢谢!
使用gem的语法如下:
social_share_button_tag("text to share")
或者如果需要 Facebook 分享按钮:
social_share_button_tag("text to share", url: 'https://www.yourdomain.com', desc: 'description for facebook')
在您的情况下,您需要将 "text to share" 替换为代码中的实际变量,可以是 @post.title 或 @ ntry.title 并为 url: 和 desc:
所以它看起来像
social_share_button_tag(@entry.title, url: @entry.url, desc: @entry.description)
希望对您有所帮助!
我一直在尝试使用社交分享按钮 gem。请参阅下面的 link。 https://github.com/huacnlee/social-share-button
但问题是我不明白什么
<%= social_share_button_tag(@post.title) %>
意思是来自link。 我正在使用控制器 'Entry,' 所以我使用了
<%= social_share_button_tag(@Entry.title) %>
但是没有用。所以我刚刚做了
<%= social_share_button_tag("") %>
它确实有效,只是当我单击显示的按钮时,它不会转到 "share link."
希望我能从中得到一些理解!谢谢!
使用gem的语法如下:
social_share_button_tag("text to share")
或者如果需要 Facebook 分享按钮:
social_share_button_tag("text to share", url: 'https://www.yourdomain.com', desc: 'description for facebook')
在您的情况下,您需要将 "text to share" 替换为代码中的实际变量,可以是 @post.title 或 @ ntry.title 并为 url: 和 desc:
所以它看起来像
social_share_button_tag(@entry.title, url: @entry.url, desc: @entry.description)
希望对您有所帮助!