升级Rails时出现语法错误:意外',',期待tASSOC(SyntaxError)

时间:2013-02-14 14:15:55

标签: ruby-on-rails-3

我一直在使用名为ajaxful-rating的宝石。现在,当我升级到Rails 3.1时,我收到以下错误:

/Users/nn/.rvm/gems/ruby-1.9.2-p290/gems/ajaxful_rating-2.2.9.1/lib/axr/model.rb:23: 
    syntax error, unexpected ',', expecting tASSOC (SyntaxError)
/Users/nn/.rvm/gems/ruby-1.9.2-p290/gems/ajaxful_rating-2.2.9.1/lib/axr/model.rb:27: syntax error, unexpected keyword_do_block, expecting keyword_end
          options[:dimensions].each do |dimension|

原始代码在上面的链接中,但相关部分如下:

def ajaxful_rateable(options = {})
  has_many :rates_without_dimension, :as => :rateable, options.merge(:class_name => 'Rate'),
    :dependent => :destroy, :conditions => {:dimension => nil}
  has_many :raters_without_dimension, :through => :rates_without_dimension, :source => :rater

  options[:dimensions].each do |dimension|
    has_many "#{dimension}_rates", :dependent => :destroy,
      :conditions => {:dimension => dimension.to_s}, :class_name => 'Rate', :as => :rateable
    has_many "#{dimension}_raters", :through => "#{dimension}_rates", :source => :rater
  end if options[:dimensions].is_a?(Array)

导致此问题的原因是什么?如何解决?

谢谢。

1 个答案:

答案 0 :(得分:1)

您必须更改以下哈希语法:

:conditions => {:dimension => nil}:conditions => [:dimension => nil]

你能尝试一下吗?

意味着您必须更改HASH语法。