Restful create URL

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

ie…localhost:3000/users/create.xml?params

new doesn’t work as it returns the empty user object in XML as it
should,
but when I call create
localhost:3000/users/create.xml?params
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.

Cheers,
SG

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
this)
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:
http://api.rubyonrails.org/classes/ActionController/Routing.html
http://api.rubyonrails.org/classes/ActionController/AbstractRequest.html

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs