Ruby-on-rails – Rails 3 – Custom XML Response

Currently I am using this:

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

I need a custom response, i.e. xml with OK If the part has been saved correctly, then OKOther.

How can I do this?

Thank you!

Something like this:

< pre>render :xml => {:result => “OK”}.to_xml

This renders

OK< /pre> 

Currently I am 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, i.e. xml with OKIf the part is saved correctly, then OKother .

How can I do this?

Thank you!

Something like this:

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

This is present

OK

Leave a Comment

Your email address will not be published.