Closed obrie closed 12 years ago
(from [41a9bb27e3729bf8b3d656c71a928fa11a8934ea]) Fix serialization failing when ActiveRecord models have been defined prior to this plugin being loaded [#2 state:resolved] http://github.com/pluginaweek/enumerate_by/commit/41a9bb27e3729bf8b3d656c71a928fa11a8934ea
Thanks for the heads up!
Emmanuel Nicolau opened this issue
If there is a model in a plugin thats get loaded before enumerate_by (like Tag in acts-as-taggable-on), then a call to Tag.new.to_xml raise this error:
NoMethodError: You have a nil object when you didn’t expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[] from /Users/Emma/Code/prueba/vendor/plugins/enumerate_by/lib/enumerate_by/extensions/serializer.rb:97:in
enumeration_association_for’ from /Users/Emma/Code/prueba/vendor/plugins/enumerate_by/lib/enumerate_by/extensions/serializer.rb:63:in
serializable_attribute_names’ from /Users/Emma/Code/prueba/vendor/plugins/enumerate_by/lib/enumerate_by/extensions/serializer.rb:63:inmap!’ from /Users/Emma/Code/prueba/vendor/plugins/enumerate_by/lib/enumerate_by/extensions/serializer.rb:63:in
serializable_attribute_names’ from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serializers/xml_serializer.rb:199:inserializable_attributes’ from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serializers/xml_serializer.rb:210:in
add_attributes’ from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serializers/xml_serializer.rb:271:inserialize’ from /Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:134:in
call’ from /Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:134:in_nested_structures’ from /Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:58:in
method_missing’ from /Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:31:intag!’ from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serializers/xml_serializer.rb:270:in
serialize’ from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serialization.rb:93:into_s’ from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serializers/xml_serializer.rb:156:in
to_xml’ from (irb):1original LH ticket
This ticket has 0 attachment(s).