gpt4 book ai didi

ruby-on-rails - acts_as_tree 和rails 3.2.3,不兼容?

转载 作者:行者123 更新时间:2023-12-03 13:43:25 25 4
gpt4 key购买 nike

我正在使用 Rails 3.2.3 和 acts_as_tree 1.1.0。我一直在将 acts_as_tree 用于一些早期版本的 Rails 3(例如 3.1.1.)的不同项目,没有出现任何问题,但它对这个版本根本不起作用。如果是因为 3.2.3 或我使用的其他东西,我无法确认。

这是我试过的,没有用:- 在几个不同的 Controller 上使用 acts_as_tree- 仅使用 acts_as_tree(没有订单声明)- 运行捆绑安装和捆绑更新- 仔细检查 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

这让我猜测 Rails 3.2.3 和 acts_as_tree 存在兼容性问题。虽然我不知道如何验证这一点。

我有哪些选择?我不一定需要使用 Rails 3.2.3,但如果我降级到 3.1.1。 (我试过了)我遇到了其他看起来更糟的问题(“文件设置”似乎不一样)。

那么,我有哪些选择?你也有过这样的经历吗? acts_as_tree 有问题,对吗?

最佳答案

看起来有一个 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

嵌套集 https://github.com/skyeagle/nested_set

编辑:

你是对的,新位置是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

这就是为什么他们没有理会那些 Unresolved 问题

关于ruby-on-rails - acts_as_tree 和rails 3.2.3,不兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10810652/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com