試圖將Rails從V4.0.4升級到4.1.0。在評論模型此語句導致運行時錯誤試圖從Rails 4.0.4升級到4.1.0 gem'acts_as_commentable_with_threading'導致錯誤
評論型號
class Comment < ActiveRecord::Base
include ActiveModel::ForbiddenAttributesProtection
# added by me so comments_on_comments sorted appropriately
default_scope { order(:updated_at => :desc) }
# causes error in rails 4.1.0
acts_as_nested_set :scope => [:commentable_id, :commentable_type]
validates :body, :presence => true
validates :user, :presence => true
...
的Gemfile
source 'https://rubygems.org'
ruby '2.1.1'
...
gem 'acts_as_commentable_with_threading', '~> 1.2.0'
原因這個錯誤在開發日誌
Unknown key: :order. Valid keys are: :class_name, :class, :foreign_key, :validate, :autosave, :table_name, :before_add, :after_add, :before_remove, :after_remove, :extend, :primary_key, :dependent, :as, :through, :source, :source_type, :inverse_of, :counter_cache
acts_as_nested_set :scope => [:commentable_id, :commentable_type] -- is highlighted
註釋掉「acts_as_nested_set:範圍=> [:commentable_id,:commentable_type]「,然後導致這個錯誤在選擇一篇文章時(對文章有評論)。
undefined method `children' for #<Comment:0x00000107260040>
非常感謝 - 在堆棧溢出方面得到了一些意見的一個原因是能夠接受答案並投票 - 謝謝 - Pierre – user1854802