evan / has_many_polymorphs

An ActiveRecord plugin for self-referential and double-sided polymorphic associations.
http://blog.evanweaver.com/files/doc/fauna/has_many_polymorphs/
Academic Free License v3.0
201 stars 57 forks source link

can't dup NilClass when trying to add an object to a list #1

Closed MagmaRules closed 15 years ago

MagmaRules commented 15 years ago

Here is my code: http://pastie.org/456077 The first time i run it, it goes ok. The second time it blows up when i add the event to the list.

It seems the second time it passes the "if record['polymorphic_parent_class']" in base.rb. The first time it doesnt enter the if.

can't dup NilClass /Users/magmarules/Sites/Probono/vendor/plugins/has_many_polymorphs/lib/has_many_polymorphs/base.rb:14:in dup' /Users/magmarules/Sites/Probono/vendor/plugins/has_many_polymorphs/lib/has_many_polymorphs/base.rb:14:ininstantiate' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:635:in find_by_sql' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:635:incollect!' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:635:in find_by_sql' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1490:infind_every' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:589:in find' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/has_many_through_association.rb:73:infind_target' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:344:in load_target' /Users/magmarules/Sites/Probono/vendor/plugins/has_many_polymorphs/lib/has_many_polymorphs/association.rb:19:in<<' /Users/magmarules/Sites/Probono/lib/tasks/import.rake:222 /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in call' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:inexecute' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in each' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:inexecute' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in invoke_with_call_chain' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:insynchronize' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in invoke_with_call_chain' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:ininvoke' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in invoke_task' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:intop_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in each' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:intop_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in standard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:intop_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in run' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:instandard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in run' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/bin/rake:31 /usr/bin/rake:19:inload' /usr/bin/rake:19

MagmaRules commented 15 years ago

Sorry my bad, i have the object named event and the relation named events and that was the problem.