目前只看到 源码 https://github.com/stefankroes/ancestry
2 年前的 demo,我的代码与之类似,跑不起来 http://railscasts.com/episodes/262-trees-with-ancestry
git:(master) ✗ rails c
Loading development environment (Rails 3.2.11)
irb(main):001:0> Category.create! :name => 'Stinky', :parent => Category.create!(:name => 'Squeeky')
(0.1ms) begin transaction
SQL (51.1ms) INSERT INTO "categories" ("ancestry", "created_at", "desc", "name", "updated_at") VALUES (?, ?, ?, ?, ?) [["ancestry", nil], ["created_at", Wed, 20 Feb 2013 03:11:29 UTC +00:00], ["desc", nil], ["name", "Squeeky"], ["updated_at", Wed, 20 Feb 2013 03:11:29 UTC +00:00]]
(1.1ms) commit transaction
ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: parent
from /usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.11/lib/active_model/mass_assignment_security/sanitizer.rb:48:in `process_removed_attributes'
from /usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.11/lib/active_model/mass_assignment_security/sanitizer.rb:20:in `debug_protected_attribute_removal'
from /usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.11/lib/active_model/mass_assignment_security/sanitizer.rb:12:in `sanitize'
from /usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.11/lib/active_model/mass_assignment_security.rb:230:in `sanitize_for_mass_assignment'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/attribute_assignment.rb:75:in `assign_attributes'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/base.rb:497:in `initialize'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/validations.rb:39:in `new'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/validations.rb:39:in `create!'
from (irb):1
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
irb(main):002:0> message = Message.new(:parent_id =>'1')
NameError: uninitialized constant Message
from (irb):2
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
irb(main):003:0>
还有别的资料么?