# Restrictings actions to post requests only

**URL:** <https://www.ruby-forum.com/t/restrictings-actions-to-post-requests-only/48868>\
**Category:** Rails\
**Created:** [November 25, 2005, 11:51pm UTC](https://www.ruby-forum.com/t/restrictings-actions-to-post-requests-only/48868 "2005-11-25T23:51:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eugenol](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/71e660/32.png) [@eugenol](https://www.ruby-forum.com/u/eugenol)\
**Post date:** [November 25, 2005, 11:51pm UTC](https://www.ruby-forum.com/t/restrictings-actions-to-post-requests-only/48868/1 "2005-11-25T23:51:17Z")

</div>

Hello

Isn’t there a new declaration for restricting actions to post requests  
only ? I cannot retrieve it in the changelog (or did I dream it ?)

Thanks !

---

<div class="post-metadata">

**Author:** ![eugenol](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/71e660/32.png) [@eugenol](https://www.ruby-forum.com/u/eugenol)\
**Post date:** [November 26, 2005, 5:29am UTC](https://www.ruby-forum.com/t/restrictings-actions-to-post-requests-only/48868/2 "2005-11-26T05:29:30Z")

</div>

If you use the @request.post? in an if statement you can write  
conditional  
code based on the request method. There is also @request.get? and @  
request.xhr?

---

<div class="post-metadata">

**Author:** ![eugenol](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/71e660/32.png) [@eugenol](https://www.ruby-forum.com/u/eugenol)\
**Post date:** [November 26, 2005, 8:38am UTC](https://www.ruby-forum.com/t/restrictings-actions-to-post-requests-only/48868/3 "2005-11-26T08:38:55Z")

</div>

On 11/26/05, Liquid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> If you use the @request.post? in an if statement you can write conditional  
> code based on the request method. There is also @request.get? and  
> @request.xhr?

No, I was thinking about declaring method writtent like has\_one :foo.  
Ex:  
post\_only :create, :delete

---

<div class="post-metadata">

**Author:** ![eugenol](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/71e660/32.png) [@eugenol](https://www.ruby-forum.com/u/eugenol)\
**Post date:** [November 26, 2005, 11:11am UTC](https://www.ruby-forum.com/t/restrictings-actions-to-post-requests-only/48868/4 "2005-11-26T11:11:56Z")

</div>

On Friday 25 November 2005 23:47, Jérôme L wrote:

> Isn’t there a new declaration for restricting actions to post  
> requests only ? I cannot retrieve it in the changelog (or did I dream  
> it ?)

See  
[http://api.rubyonrails.org/classes/ActionController/Verification/ClassMethods.html](http://api.rubyonrails.org/classes/ActionController/Verification/ClassMethods.html)

Michael

–  
Michael S. Life is what happens  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) While you’re making plans  
[Michael Schürig | Sentenced to making sense](http://www.schuerig.de/michael/) --Kevin Gilbert, A Long Day’s Life
