3

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!

1 Answer 1

7

Something like this:

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

This renders

<result>OK</result>
Sign up to request clarification or add additional context in comments.

2 Comments

Oh thank you very much for your answer! Please, can i ask you where could i have found this information myself?
You can find it in the rails documentation. apidock.com/rails/ActionController/Base/render

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.