# How to set response status to :created?

**URL:** <https://www.ruby-forum.com/t/how-to-set-response-status-to-created/113119>\
**Category:** Rails\
**Created:** [August 27, 2007, 8:34pm UTC](https://www.ruby-forum.com/t/how-to-set-response-status-to-created/113119 "2007-08-27T20:34:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eggie5](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7c8e57/32.png) [@eggie5](https://www.ruby-forum.com/u/eggie5)\
**Post date:** [August 27, 2007, 8:34pm UTC](https://www.ruby-forum.com/t/how-to-set-response-status-to-created/113119/1 "2007-08-27T20:34:09Z")

</div>

I want my response to include either the json or xml text, but I also  
want it to include the http status 201. How can I do this?  
if @manufacturer.save  
format.xml { render :xml =\> @manufacturer.to\_xml }  
format.json { render :json =\> @manufacturer.to\_json }  
end

---

<div class="post-metadata">

**Author:** ![eggie5](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7c8e57/32.png) [@eggie5](https://www.ruby-forum.com/u/eggie5)\
**Post date:** [August 27, 2007, 8:38pm UTC](https://www.ruby-forum.com/t/how-to-set-response-status-to-created/113119/2 "2007-08-27T20:38:09Z")

</div>

On 8/27/07, eggie5 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I want my response to include either the json or xml text, but I also  
> want it to include the http status 201. How can I do this?  
> if @manufacturer.save  
> format.xml { render :xml =\> @manufacturer.to\_xml }  
> format.json { render :json =\> @manufacturer.to\_json }  
> end

add :status =\> :created after your render line…?

---

<div class="post-metadata">

**Author:** ![eggie5](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7c8e57/32.png) [@eggie5](https://www.ruby-forum.com/u/eggie5)\
**Post date:** [August 27, 2007, 10:52pm UTC](https://www.ruby-forum.com/t/how-to-set-response-status-to-created/113119/3 "2007-08-27T22:52:30Z")

</div>

thanks
