我有一个名为的模型Collection
,其配置如下:
acts_as_nested_set scope: :account, dependent: :destroy
belongs_to :parent, class_name: 'Collection'
nested_set_options
在我升级到 Rails 4.1.4(从 4.0.5 升级)之前,使用视图助手工作正常:
<%= f.input :parent_id, label: 'Parent Collection',
collection: nested_set_options(@collections) { |collection|
"#{'-' * collection.level} #{collection.name}"
},
include_blank: '-- No Parent --' %>
我得到这个例外:
undefined method `name' for nil:NilClass
/Users/cpeters/Sites/plugins/awesome_nested_set/lib/awesome_nested_set/model.rb:45:in `add_to_inverse_association'
/Users/cpeters/Sites/plugins/awesome_nested_set/lib/awesome_nested_set/model.rb:37:in `block in associate_parents'
activerecord (4.1.4) lib/active_record/relation/delegation.rb:46:in `each'
activerecord (4.1.4) lib/active_record/relation/delegation.rb:46:in `each'
/Users/cpeters/Sites/plugins/awesome_nested_set/lib/awesome_nested_set/model.rb:31:in `associate_parents'
/Users/cpeters/Sites/plugins/awesome_nested_set/lib/awesome_nested_set/helper.rb:33:in `block in nested_set_options'
/Users/cpeters/Sites/plugins/awesome_nested_set/lib/awesome_nested_set/helper.rb:32:in `each'
/Users/cpeters/Sites/plugins/awesome_nested_set/lib/awesome_nested_set/helper.rb:32:in `nested_set_options'
app/views/admin/resources/collections/_form.html.erb:7:in `block in _app_views_admin_resources_collections__form_html_erb__1427458998633439544_70350945783440'
这是从 GitHub 运行的最新版本(提交f823ffb)。