2014-11-01 94 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