# Return an unauthorised header unless the request format is x

**URL:** <https://www.ruby-forum.com/t/return-an-unauthorised-header-unless-the-request-format-is-x/111570>\
**Category:** Rails\
**Created:** [August 8, 2007, 6:08pm UTC](https://www.ruby-forum.com/t/return-an-unauthorised-header-unless-the-request-format-is-x/111570 "2007-08-08T18:08:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobycatlin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@tobycatlin](https://www.ruby-forum.com/u/tobycatlin)\
**Post date:** [August 8, 2007, 6:08pm UTC](https://www.ruby-forum.com/t/return-an-unauthorised-header-unless-the-request-format-is-x/111570/1 "2007-08-08T18:08:03Z")

</div>

Hi,

I’d like to return a header that indicates an action is unauthorised  
unless the request was an xml request. I’m using REST in my  
controllers and I only want create, delete and update capability for  
those requests that come from activerecord.

How do I just return the relevant headers without performing the  
action when create, delete or update requests come in from html?

so far I have:

head :unauthorized(?) unless request.format.xml?

I don’t think :unauthorized exists as one of the status’ I just put it  
in to show what I am trying to do.

I tried a before filter that renders that header but that causes two a  
double render error.

Any suggestions?

Toby

---

<div class="post-metadata">

**Author:** ![tobycatlin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@tobycatlin](https://www.ruby-forum.com/u/tobycatlin)\
**Post date:** [August 8, 2007, 6:36pm UTC](https://www.ruby-forum.com/t/return-an-unauthorised-header-unless-the-request-format-is-x/111570/2 "2007-08-08T18:36:10Z")

</div>

Sorry when I said activerecord above I meant activeresource.
