ruby on rails - activerecord to_xml update xml version to 1.1 -


the to_xml activerecord include xml declaration follows.

<?xml version="1.0" encoding="utf-8"?> 

how change version 1.1 , change encoding?

we can use to_xml(:skip_instruct => true) hide declaration altogether.

if using restfull routes visiting some_url.xml give results have described. if way serving xml can define own xml builder template. work in same way view works here example

your controller action

  def show     @obj = someclass.find(params[:id])      respond_to |format|       format.html # show.html.erb       format.xml  { render :layout => false }     end   end 

then in views folder place show.html.erb create show.xml.builder file contents looking this

xml.someclass   xml.id(@obj.id)   xml.name(@obj.name) end 

in template can add <?xml version="1.1" encoding="utf-8"?> or whatever xml declarations wish add

update don't need serving views, restfull route, controller , action has respond_to respondes xml format. rails pick want render xml , .xml.erb file in views folder named after action in same way views work


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -