Think of the following models: class User < ActiveRecord::Base has_many :created_entities, :class_name => "Entity", :foreign_key => "created_by" end
class Entity < ActiveRecord::Base belongs_to :created_by, :class_name => "User", :foreign_key => "created_by" end There is also a created_by integer field in the Entity migration. Everything seems to work fine with these model (fetching the association and so on), but when I try to serialize Entity.to_xml :include => :created_by (or include something other the model has as association) it fails (NoMethodError: undefined method `macro' for nil:NilClass). For full trace see: http://stackoverflow.com/questions/4217923/nomethoderror-when-serializing-to-xml But as soon as I rename the association in the Entity model to: belongs_to :creator, :class_name => "User", :foreign_key => "created_by" the serialization to_xml start to work again. Im using Rails 3.0.1. Can someone reproduce that? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

