参数数量错误(1 代表 0)(社交宝石) [英] wrong number of arguments (1 for 0) (Social Gem )

查看:49
本文介绍了参数数量错误(1 代表 0)(社交宝石)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在使用这个社交宝石,但由于某种原因我收到以下错误:

参数个数错误(1 代表 0)

这是导致错误的代码行:

 <%= tweet_button(via: "peterc", url: "http://news.ycombinator.com", :text => "AWESOME.") %>

不确定我做错了什么,我已经非常彻底地阅读了 gem 上的文档.

过去 2 周我一直在做这件事,但运气不佳.. 非常感谢能提供帮助的人.

更新;

参数个数错误(1 代表 0)提取的源代码(围绕第 27 行):24252627282930<div class="social-buttons"><%= link_to 'Share on Facebook', '', class: "zocial facebook" %><%= link_to 'Share on Twitter', '', class: "zocial twitter" %><div class="zocial twitter"><%= tweet_button(via: "peterc", url: "http://news.ycombinator.com", :text => "AWESOME.") %>

<a id="meetflappy"></a>模板包含痕迹:app/views/preorder/homepage/_show_dont_tell.html.erb, app/views/preorder/index.html.erbRails.root:/Users/user/Sites/selfstarter应用程序跟踪 |框架跟踪 |完整跟踪app/helpers/preorder_helper.rb:9:in`tweet_button'app/views/preorder/homepage/_stats.html.erb:27:in`_app_views_preorder_homepage__stats_html_erb___583266768877320144_70197372691940'app/views/preorder/homepage/_show_dont_tell.html.erb:2:在`_app_views_preorder_homepage__show_dont_tell_html_erb___1987989831881903472_70197362850480'app/views/preorder/index.html.erb:2:在`_app_views_preorder_index_html_erb__3522201633818553639_70197398947440'

更新 2

模块 PreorderHelperdef like_button(width = 70, show_faces = false)raw "<div class=\"fb-like\" data-send=\"false\" data-width=\"#{width}\" data-layout=\"box_count\" data-show-faces=\"真\"></div>"结尾def pin_it_buttonimage_url = URI.encode("#{request.scheme}://#{request.host}#{image_path(Settings.product_image_path)}")raw "<a href='http://pinterest.com/pin/create/button/?url=#{encoded_root_url}&media=#{image_url}' class='pin-it-button' count-layout='vertical'><img border='0' src='//assets.pinterest.com/images/PinExt.png' title='Pin It'/></a>"结尾def tweet_buttontweet_text = "我是 #{Settings.primary_stat_verb} number #{number_with_delimiter Order.backers, :delimiter => ","} #{Settings.tweet_text}!"raw "<a href='https://twitter.com/share?url=/' id='tweet_button' class='twitter-share-button twitter-button' data-url=#{request.scheme}//#{request.host}' data-via='#{Settings.product_name}' data-lang='en' data-count='vertical' data-text=\"#{tweet_text}\">Tweet</a>"结尾def video_url#{Settings.video_embed_url}?"+ case Settings.video_embed_url当/vimeo/'title=0&byline=0&portrait=0&autoplay=0'当/youtube/'自动隐藏=1&showinfo=0&rel=0&autoplay=0'别的''结尾结尾def encoding_root_url原始 URI.encode "#{request.scheme}://#{request.host}/preorder"结尾def sell_out(payment_option)payment_option.limit >-1 和 order_count(payment_option) >= payment_option.limit结尾def order_count(payment_option)Order.where(payment_option_id: payment_option).count(:token) # 拥有来自亚马逊的代币并用于此支付选项的订单数量结尾结尾

解决方案

PreorderHelper 中移除 tweet_button 方法,因为它覆盖了 tweet_buttonsocial-buttons gem 的方法.

So I'm using this social gem but for some reason I'm getting the following error:

wrong number of arguments (1 for 0)

and this is the line of code that's causing the error:

   <%= tweet_button(via: "peterc", url: "http://news.ycombinator.com", :text => "AWESOME.")  %>

Not sure what I'm doing wrong, I've read the Documentation on the gem quite thoroughly.

I've spent the last 2 weeks straight on this, with no luck.. whoever can help would be REALLY appreciated.

Update;

wrong number of arguments (1 for 0)
Extracted source (around line #27):
24
25
26
27
28
29
30

     <div class="social-buttons">
       <%= link_to 'Share on Facebook', '', class: "zocial facebook" %>
       <%= link_to 'Share on Twitter', '', class: "zocial twitter" %>
       <div class="zocial twitter"><%= tweet_button(via: "peterc", url: "http://news.ycombinator.com", :text => "AWESOME.")  %></div>

     </div>
     <a id="meetflappy"></a>

Trace of template inclusion: app/views/preorder/homepage/_show_dont_tell.html.erb, app/views/preorder/index.html.erb

Rails.root: /Users/user/Sites/selfstarter

Application Trace | Framework Trace | Full Trace
app/helpers/preorder_helper.rb:9:in `tweet_button'
app/views/preorder/homepage/_stats.html.erb:27:in `_app_views_preorder_homepage__stats_html_erb___583266768877320144_70197372691940'
app/views/preorder/homepage/_show_dont_tell.html.erb:2:in `_app_views_preorder_homepage__show_dont_tell_html_erb___1987989831881903472_70197362850480'
app/views/preorder/index.html.erb:2:in `_app_views_preorder_index_html_erb__3522201633818553639_70197398947440'

Update 2

module PreorderHelper
  def like_button(width = 70, show_faces = false)
    raw "<div class=\"fb-like\" data-send=\"false\" data-width=\"#{width}\" data-layout=\"box_count\" data-show-faces=\"true\"></div>"
  end
  def pin_it_button
    image_url = URI.encode("#{request.scheme}://#{request.host}#{image_path(Settings.product_image_path)}")
    raw "<a href='http://pinterest.com/pin/create/button/?url=#{encoded_root_url}&media=#{image_url}' class='pin-it-button' count-layout='vertical'><img border='0' src='//assets.pinterest.com/images/PinExt.png' title='Pin It' /></a>"
  end
  def tweet_button
    tweet_text = "I'm #{Settings.primary_stat_verb} number #{number_with_delimiter Order.backers, :delimiter => ","} #{Settings.tweet_text}!"
    raw "<a href='https://twitter.com/share?url=/' id='tweet_button' class='twitter-share-button twitter-button' data-url=#{request.scheme}//#{request.host}' data-via='#{Settings.product_name}' data-lang='en' data-count='vertical' data-text=\"#{tweet_text}\">Tweet</a>"
  end

  def video_url
    "#{Settings.video_embed_url}?" + case Settings.video_embed_url
    when /vimeo/
      'title=0&byline=0&portrait=0&autoplay=0'
    when /youtube/
      'autohide=1&showinfo=0&rel=0&autoplay=0'
    else
      ''
    end
  end

  def encoded_root_url
    raw URI.encode "#{request.scheme}://#{request.host}/preorder"
  end

  def sold_out(payment_option)
    payment_option.limit > -1 and order_count(payment_option) >= payment_option.limit
  end

  def order_count(payment_option)
    Order.where(payment_option_id: payment_option).count(:token) # count of orders that have a token from amazon and are for this payment option
  end
end

解决方案

Remove tweet_button method from the PreorderHelper as it is overriding the tweet_button method of social-buttons gem.

这篇关于参数数量错误(1 代表 0)(社交宝石)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆