我正在使用Rails 3.2.3和acts_as_tree 1.1.0。我一直使用acts_as_tree來處理早期版本的Rails 3(比如3.1.1)的一些不同的項目,但沒有任何問題,但對於這個版本根本不起作用。如果是因爲3.2.3或其他我使用的東西,我還沒有能夠確認。acts_as_tree和rails 3.2.3不兼容?
這是我已經試過了,沒有用: - 對幾個不同的控制器 使用acts_as_tree - 只有使用acts_as_tree(沒有order語句) - 運行包安裝包更新 - 仔細檢查PARENT_ID存在,是整數
首先,當我嘗試這樣做,在我第一次嘗試了:
undefined method `acts_as_tree'
重新加載頁面(而不是做別的)引起的:
undefined method `key?' for nil:NilClass
然後重新啓動服務器造成發射失敗(應用程序會崩潰和無法啓動),出現以下錯誤:
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require': /Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:78: odd number list for Hash (SyntaxError)
foreign_key: "parent_id",
^
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:78: syntax error, unexpected ':', expecting '}'
foreign_key: "parent_id",
^
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:78: syntax error, unexpected ',', expecting kEND
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:79: Can't assign to nil
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:80: syntax error, unexpected ':', expecting '='
counter_cache: nil,
^
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:80: Can't assign to nil
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:81: syntax error, unexpected ':', expecting '='
dependent: :destroy
^
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:82: syntax error, unexpected '}', expecting kEND
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:86: syntax error, unexpected ':', expecting kEND
belongs_to :parent, class_name: name,
^
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:87: syntax error, unexpected ':', expecting '='
foreign_key: configuration[:foreign_key],
^
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:88: syntax error, unexpected ':', expecting '='
counter_cache: configuration[:counter_cache],
^
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:89: syntax error, unexpected ':', expecting '='
inverse_of: :children
^
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:91: syntax error, unexpected ':', expecting kEND
has_many :children, class_name: name,
^
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:92: syntax error, unexpected ':', expecting '='
foreign_key: configuration[:foreign_key],
^
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:93: syntax error, unexpected ':', expecting '='
order: configuration[:order],
^
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:94: syntax error, unexpected ':', expecting '='
dependent: configuration[:dependent],
^
/Library/Ruby/Gems/1.8/gems/acts_as_tree-1.1.0/lib/acts_as_tree.rb:95: syntax error, unexpected ':', expecting '='
inverse_of: :parent
^
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler.rb:119:in `require'
from /Users/Christoffer/Documents/Webbprojekt/rails/Presenttips/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:53:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:53
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:50:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:50
from script/rails:6:in `require'
from script/rails:6
這讓我想有一個保持兼容問題BTW的Rails 3.2.3和acts_as_tree。我不知道如何驗證這一點。
我有什麼選擇?我不一定需要使用Rails 3.2.3,但是如果我降級到3.1.1。 (我試過)我遇到了其他更糟糕的問題(「文件設置」似乎不一樣)。
那麼,我有什麼選擇?你有沒有體驗過這個? acts_as_tree有問題,對嗎?
打擾。我看不出你所鏈接的問題是如何相關的。從未聽說過acts_as_tree_rails3,並且不需要將其用於3.1.1。但我很高興它的工作。謝謝! – Christoffer
謝謝它適合我。 –