visionmedia / express-resource

Resourceful routing for Express
1.41k stars 140 forks source link

Behavioral differences between RESTful rails and express-resource #40

Closed supr closed 12 years ago

supr commented 12 years ago

When i create a restful scaffold in rails like

GET /resource/:id/edit i am greeted with a form that does a POST to /resource/:id. But for a similar resource if i post to /resource/:id from the /resource/:id/edit form i get a Cannot POST. If this is unavailable how can a web-application update a resource via HTML form.

Thanks

tj commented 12 years ago

why post to /resource/:id when you have no id? letting the client determine the id is not safe, so we have POST /resource

supr commented 12 years ago

My understanding is that posting to /resource is for create and not update. I can try to check for the id in body and maybe update the resource that way. But, i am looking for a cleaner way to do that

tj commented 12 years ago

yeah create == POST /video update == PUT /video/:id

pvencill commented 12 years ago

@visionmedia I think he means that HTML(4) forms can't do a PUT operation.

@supr: Express recognizes the method override param, so you can add into your form. Unless I'm mistaken, your form method should still be a POST to /resource/:id unless you're writing for clients that support PUT (in whcih case it'd be a PUT to /resource/:id.

supr commented 12 years ago

@pvencill Yes, the inability of HTML to PUT to a resource is what i am interested in.

tj commented 12 years ago

use methodOverride() + _method

supr commented 12 years ago

Thanks.