pluginaweek / enumerate_by

Adds support for declaring an ActiveRecord class as an enumeration
http://www.pluginaweek.org
MIT License
38 stars 9 forks source link

Xml serialization on plugin models #2

Closed obrie closed 12 years ago

obrie commented 12 years ago

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:inserializable_attribute_names’ from /Users/Emma/Code/prueba/vendor/plugins/enumerate_by/lib/enumerate_by/extensions/serializer.rb:63:in map!’ from /Users/Emma/Code/prueba/vendor/plugins/enumerate_by/lib/enumerate_by/extensions/serializer.rb:63:inserializable_attribute_names’ from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serializers/xml_serializer.rb:199:in serializable_attributes’ from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serializers/xml_serializer.rb:210:inadd_attributes’ from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serializers/xml_serializer.rb:271:in serialize’ from /Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:134:incall’ 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:inmethod_missing’ from /Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:31:in tag!’ from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serializers/xml_serializer.rb:270:inserialize’ from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serialization.rb:93:in to_s’ from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serializers/xml_serializer.rb:156:into_xml’ from (irb):1

original LH ticket

This ticket has 0 attachment(s).

obrie commented 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

obrie commented 12 years ago

Thanks for the heads up!