2014-11-01 176 views
0

我instance_methods执行bundle exec rake db:migrate错误,同时运行捆绑高管耙分贝:迁移

/usr/lib/ruby/gems/1.8/gems/ancestry-2.1.0/lib/ancestry/instance_methods.rb:77: syntax error, unexpected ':', expecting ')' 
      self.class.where(id: (ancestor_ids + ancestor_ids_... 
          ^
/usr/lib/ruby/gems/1.8/gems/ancestry-2.1.0/lib/ancestry/instance_methods.rb:77: syntax error, unexpected ')', expecting kEND 
..._ids + ancestor_ids_was).uniq).each do |ancestor| 

实际的代码后,得到了以下错误是

触摸每个这张唱片的祖先

def touch_ancestors_callback 

    # Skip this if callbacks are disabled 
    unless ancestry_callbacks_disabled? 

    # Only touch if the option is enabled 
    if self.ancestry_base_class.touch_ancestors 

     # Touch each of the old *and* new ancestors 
     self.class.where(id: (ancestor_ids + ancestor_ids_was).uniq).each do |ancestor| 
     ancestor.without_ancestry_callbacks do 
      ancestor.touch 
     end 
     end 
    end 
    end 
end 

我的与 https://github.com/stefankroes/ancestry/blob/master/lib/ancestry/instance_methods.rb#L97 比较的代码我不明白为什么我得到该错误。请帮助我。

预先感谢您。

+1

你使用宝石不兼容版本的红宝石。至少使用ruby 2.0。 – 2014-11-01 22:11:27

回答

1

这个gem使用Ruby 1.9引入的哈希的新语法。但是你用Ruby 1.8运行这个代码什么不明白这个语法。

你有两个选择:

  • 找到并使用了一个“老”的语法宝石的旧版本。如果一个版本甚至存在取决于宝石的年龄。或者

  • 升级到更新的Ruby版本。

我会建议升级红宝石,因为1.8是过时多年了,并没有得到安全更新了(阅读:https://www.ruby-lang.org/en/news/2013/12/17/maintenance-of-1-8-7-and-1-9-2/

+0

我发现与红宝石1.8兼容的祖先1.2.5。现在它成功执行了。谢谢。 – satyanarayana 2014-11-02 17:53:43

相关问题