# POST and GET

**URL:** <https://www.ruby-forum.com/t/post-and-get/192560>\
**Category:** Rails\
**Created:** [August 2, 2010, 7:01am UTC](https://www.ruby-forum.com/t/post-and-get/192560 "2010-08-02T07:01:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![devrubygem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@devrubygem](https://www.ruby-forum.com/u/devrubygem)\
**Post date:** [August 2, 2010, 7:01am UTC](https://www.ruby-forum.com/t/post-and-get/192560/1 "2010-08-02T07:01:52Z")

</div>

HEY Guys,

Im new to rails. Can someone help explain POST and GET inrails, and  
maybe give an example? When is it used? Im learning rails via Agile web  
Development with Rails, and soon to download peepcode video’s, are these  
good resources to learn from?

Regards

---

<div class="post-metadata">

**Author:** ![devrubygem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@devrubygem](https://www.ruby-forum.com/u/devrubygem)\
**Post date:** [August 2, 2010, 7:16am UTC](https://www.ruby-forum.com/t/post-and-get/192560/2 "2010-08-02T07:16:46Z")

</div>

C=create=post=insert  
R=read=get=select  
U=update=put=update  
D=delete=delete=delete

POST & GET are part of the http standard. Check out the fielding  
dissertation they’re two of I think 9 methods

> **[HTTP](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol)**
>
> The Hypertext Transfer Protocol (HTTP) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, where hypertext documents include hyperlinks to other resources that the user can easily access, for example by a mouse click or by tapping the screen in a web browser.
> Development of HTTP was initiated by Tim Berners-Lee at CERN in 1989 and summarized in ...

[http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm](http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm)

When you submit a form without an opaque query string you are POSTing.  
When  
you grab the variables from a query string you are getting your GET on.

I just got the Agile WDwR beta copy. Interesting stuff. I would check  
out  
different API’s like Twitter, Gowalla, etc and see how they expose their  
data/we seb service.

RESTful in peace,  
angel

---

<div class="post-metadata">

**Author:** ![devrubygem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@devrubygem](https://www.ruby-forum.com/u/devrubygem)\
**Post date:** [August 2, 2010, 7:35am UTC](https://www.ruby-forum.com/t/post-and-get/192560/3 "2010-08-02T07:35:30Z")

</div>

GET

- typically used when you access a page via a link (ie you cut and  
paste into the web browser)
- all the values (ie form arguments) get passed in the url itself  
( delimited by the ampersand character)
- example: when the following link is copied and pasted to the web  
browser, a GET request is generated and the values for  
distance,N,Make , state and so forth are passed in the url itself.  
[http://www.carsales.com.au/used-cars/MITSUBISHI/LANCER/private-results.aspx?distance=25&N=4294964597+0+4294966896+4294803479&Make=MITSUBISHI&state\_id=0&Model=LANCER&State=All%20States](http://www.carsales.com.au/used-cars/MITSUBISHI/LANCER/private-results.aspx?distance=25&N=4294964597+0+4294966896+4294803479&Make=MITSUBISHI&state_id=0&Model=LANCER&State=All%20States)

POST

- can only be generated by a form’s submit action/button
- all the values (ie form arguments) get passed in the “params” hence  
in rails, you access the values via “params”
- example: in search forms or registration forms, clicking the submit  
button generates a POST request to the web server

Gordon Y.

---

<div class="post-metadata">

**Author:** ![devrubygem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@devrubygem](https://www.ruby-forum.com/u/devrubygem)\
**Post date:** [August 2, 2010, 5:05pm UTC](https://www.ruby-forum.com/t/post-and-get/192560/4 "2010-08-02T17:05:11Z")

</div>

Also, a GET is just a read, while a POST is used to create. Like the  
Wikipedia article linked before says:

> Note that GET should not be used for operations that cause side-effects, such as using it for taking actions in web applications.

---

<div class="post-metadata">

**Author:** ![devrubygem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@devrubygem](https://www.ruby-forum.com/u/devrubygem)\
**Post date:** [August 3, 2010, 5:09am UTC](https://www.ruby-forum.com/t/post-and-get/192560/5 "2010-08-03T05:09:12Z")

</div>

Adam S. wrote:

> Also, a GET is just a read, while a POST is used to create. Like the  
> Wikipedia article linked before says:
> 
> > Note that GET should not be used for operations that cause side-effects, such as using it for taking actions in web applications.

Thanks guys this really helped out alot, Thank You 🙂

---

<div class="post-metadata">

**Author:** ![devrubygem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@devrubygem](https://www.ruby-forum.com/u/devrubygem)\
**Post date:** [August 2, 2010, 8:01am UTC](https://www.ruby-forum.com/t/post-and-get/192560/6 "2010-08-02T08:01:15Z")

</div>

To add, in relation to a GET request, there is a limit of number of  
characters that a url can be made of.

> <https://stackoverflow.com/questions/1496080/limitation-of-url>

Cheers

Gordon Y. 🙂
