Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 - custom XML response

currently i'm using this:

if @part.save
  format.xml  { render :xml => @part, :status => :created, :location => @part }
else
  format.xml  { render :xml => @part.errors, :status => :unprocessable_entity }
end

i need a custom response, that is an xml with <result>OK</result> if the part was correctly saved, and <result>OK</result> else.

How can i do this?

Thanks!

like image 410
Abramodj Avatar asked Jun 01 '26 23:06

Abramodj


1 Answers

Something like this:

render :xml => {:result => "OK"}.to_xml

This renders

<result>OK</result>
like image 116
dombesz Avatar answered Jun 03 '26 12:06

dombesz