Ruby on Rails中的社交媒体共享按钮 [英] Social Media sharing Buttons in Ruby on Rails

查看:101
本文介绍了Ruby on Rails中的社交媒体共享按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Ruby on Rails的博客应用程序中添加自定义社交媒体共享按钮.对于我来说很重要的是,将显示一个弹出窗口以共享帖子",这意味着我要包含Javascript.

I'm trying to add custom social media sharing buttons in a blog app in Ruby on Rails. It is important for me that a pop-up window will show for sharing the "post" meaning I want to include Javascript.

不幸的是,此代码不起作用:

Unfortunately this code does not work:

  <!-- Twitter -->
  <a oneclick="javascript:window.open('http://twitter.com/share?text=<%= @post.title %> 
  by Martin Bortowski - &amp;url=<%= url_for([@post, {only_path: false}]) %>',
  '_blank', 'width=800, height=500, top=200, left=300');void(0);"><i class="fa fa-twitter"></i></a>

  <!-- Facebook -->
  <a oneclick="javascript:window.open('http://facebook.com/sharer.php?u=<%= url_for([@post, {only_path: false}]) %>',
  '_blank', 'width=800, height=500, top=200, left=300');void(0);"><i class="fa fa-facebook"></i></a>

  <!-- Google Plus -->
  <a oneclick="javascript:window.open('https://plus.google.com/share?url=<%= url_for([@post, {only_path: false}]) %>',
  '_blank', 'width=800, height=500, top=200, left=300');void(0);"><i class="fa fa-google-plus"></i></a>

当我单击一个按钮时,什么也没有发生.我想念的是什么?有谁可以帮助我吗?如果您需要更多信息,请告诉我.

When I click on a button nothing happens. What I am missing? Can someone help me please? If you need further information just let me know.

推荐答案

下面有一些链接中的红宝石可用于实现社交功能,这些链接很少见

There are number of gems available in ruby on rails for implementing social shairing feature below are few links

  1. https://github.com/huacnlee/social-share-button
  2. https://github.com/hermango/shareable
  1. https://github.com/huacnlee/social-share-button
  2. https://github.com/hermango/shareable

这篇关于Ruby on Rails中的社交媒体共享按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆