to_xml with :only and :methods
- by Jake
I'm calling to_xml on an ActiveRecord object with both :only and :methods parameters.
The method that I'm including returns a collection for AR objects. This works fine without the :only param, but when that is added I just get the default to_s representation of my objects.
i.e
<author><books>#<Book:0x107753228></books>\n</author>
Any ideas?
Update, here is the code:
class Author < ActiveRecord::Base
def books
#this is a named scope
products.by_type(:book)
end
end
Author.to_xml(:methods => :books, :only => :id)