I’m creating and api.
I create a scaffold
script/generate scaffold user
I have users controller, but how do I call the create method via a URL
new doesn’t work as it returns the empty user object in XML as it
but when I call create
I get the below error
“Couldn’t find User with ID=create”
I get that is has to do with the routing, but I don’t want to call
create with and ID as I don’t know what it is going to be.
Any help is apperciated.
As you now URL its a GET method, but according
RESTful rules create it’s a POST method.
Rails defines seven controller methods for RESTful resources by
convention. They are:
Action HTTP Method Purpose
index GET Displays a collection of resources
show GET Displays a single resource
new GET Displays a form for creating a new resource
create POST Creates a new resource (new submits to this)
edit GET Displays a form for editing an existing resource
update PUT Updates an existing resource (edit submits to
destroy DELETE Destroys a single resource
You can find out it your self by:
$ rake routes
If you still want use create action by GET method you can reach it by
routes.rb file. Following links help you figure out it: