Why is there a need to define a new method in RESTful controller, follow it up with a create method?
Google search didn’t provide me the answer I was looking for. I understand the difference, but need to know why they are used the way they are.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Within Rails’ implementation of REST new and create are treated differently.
An HTTP GET to
/resources/newis intended to render a form suitable for creating a new resource, which it does by calling the new action within the controller, which creates a new unsaved record and renders the form.An HTTP POST to
/resourcestakes the record created as part of the new action and passes it to the create action within the controller, which then attempts to save it to the database.