Closed MagmaRules closed 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
dup' /Users/magmarules/Sites/Probono/vendor/plugins/has_many_polymorphs/lib/has_many_polymorphs/base.rb:14:in
find_by_sql' /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:in
find' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/has_many_through_association.rb:73:in
load_target' /Users/magmarules/Sites/Probono/vendor/plugins/has_many_polymorphs/lib/has_many_polymorphs/association.rb:19:in
call' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in
each' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in
invoke_with_call_chain' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in
invoke_with_call_chain' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in
invoke_task' /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:in
standard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in
run' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in
run' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/bin/rake:31 /usr/bin/rake:19:in
Sorry my bad, i have the object named event and the relation named events and that was the problem.
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:in
instantiate' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:635:infind_by_sql' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:635:in
collect!' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:635:infind_by_sql' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1490:in
find_every' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:589:infind' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/has_many_through_association.rb:73:in
find_target' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:344:inload_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:incall' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in
execute' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:ineach' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in
execute' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:ininvoke_with_call_chain' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in
synchronize' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:ininvoke_with_call_chain' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in
invoke' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:ininvoke_task' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in
top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:ineach' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in
top_level' /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:1999:in
top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:inrun' /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:1974:inrun' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/bin/rake:31 /usr/bin/rake:19:in
load' /usr/bin/rake:19