Tuesday, July 08, 2008

Rails: How to render a xml document from a model ?

Rails is great !

def last
@movies = Movie.find(:all, :limit=>15, :order=>'created_at desc')
render :xml => @movies
end

1 comment:

Benjamin Francisoud said...

It use the generic method to_xml in active_record I think...

Didn't check but I think there is also "to_json" to have a json view of the data ;)