2012-05-30 65 views
3

我正在使用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有问题,对吗?

回答

3

貌似有一个从2年前开放

opened this issue 2 years ago Does not work with Rails 2.3.8 https://github.com/rails/acts_as_tree/issues/1

选项

acts_as_tree_rails3 gem install acts_as_tree_rails3

nested_set https://github.com/skyeagle/nested_set

Ë DIT:

你是对的,新的位置是https://github.com/amerine/acts_as_tree同一作者

与评论

We no longer support Ruby 1.8 or versions if Rails/ActiveRecord older than 3.0. If you're using a version of ActiveRecord older than 3.0 please use 0.1.1.

Moving forward we will do our best to support the latest versions of ActiveRecord and Ruby

这就是为什么他们不使用acts_as_tree_rails3的伎俩那些打开的问题

+0

打扰。我看不出你所链接的问题是如何相关的。从未听说过acts_as_tree_rails3,并且不需要将其用于3.1.1。但我很高兴它的工作。谢谢! – Christoffer

+0

谢谢它适合我。 –