views:

254

answers:

2
+4  Q: 

Restful commands

I am new to RESTful stuff. But, I want to use it in my rails app. When I add this to my routes.rb map.resources :notes I get routes to these methods created:

  • index
  • create
  • new
  • edit
  • show
  • update
  • destroy

What I am wondering is what is the difference between edit/update and create/new? Is there any standard definitions of how these method pairs vary and what each one does?

+4  A: 

When you use the scaffold generator in Rails 2 create is the action called when the form from the new action is submitted. Likewise, update is the action called when the form from the edit action is submitted.

As far as I know, you can blow that away and define them to do whatever you want depending on what create/new/edit/update means to your application.

Owen
+12  A: 

The standard definition is as follows:

  • index - GET - A view of all (or a selection of) the records
  • show - GET - A view of a single record
  • new - GET - A form to post to create
  • create - POST - Create a new record
  • edit - GET - A form to edit a single record
  • update - PUT - Update a record
  • destroy - DELETE - Delete a record
Jon Wood