Josh Moore
Josh Moore

Reputation: 13548

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:

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?

Upvotes: 5

Views: 586

Answers (2)

Jon Wood
Jon Wood

Reputation: 2589

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

Upvotes: 13

Owen
Owen

Reputation: 22897

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.

Upvotes: 5

Related Questions