ruby-on-rails - 带有导轨的社交共享按钮宝石中的错误
问题描述
我一直在尝试使用社交分享按钮 gem。请参阅下面的链接。https://github.com/huacnlee/social-share-button
但问题是我不明白什么
<%= social_share_button_tag(@post.title) %>
从链接的意思。我正在使用控制器“条目”,所以我做到了
<%= social_share_button_tag(@Entry.title) %>
但它没有用。所以我只是做了
<%= social_share_button_tag("") %>
它确实有效,只是当我单击显示的按钮时,它没有转到“共享链接”。
希望我能从中得到一些理解!谢谢!
解决方案
使用 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')
在您的情况下,您需要用代码中的实际变量替换“要共享的文本”,可以是@post.title或@ntry.title并为url:和desc:
所以它看起来像
social_share_button_tag(@entry.title, url: @entry.url, desc: @entry.description)
希望能帮助到你!
推荐阅读
- google-apps-marketplace - 如何获取 Gsuite Marketplace 应用安装记录
- javascript - 您如何制作书签更改页面图标?
- python - 类中的python合并排序
- php - PHP骰子游戏直到机器猜到1
- excel - 将非时间字符串转换为 HH:MM
- python - 单击时画布上的 tkinter 条目小部件效果
- vba - 如何更改 vba 中形状文本的样式?
- android - 使用 null 数组而不是可选数组
- scala - Spark Scala 上的 java.lang.NullPointerException 问题
- python - 如何将串行输入拆分为消息