Abramodj
Abramodj

Reputation: 5879

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!

Upvotes: 3

Views: 2945

Answers (1)

dombesz
dombesz

Reputation: 7899

Something like this:

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

This renders

<result>OK</result>

Upvotes: 7

Related Questions