As per the this Cakephp CookBook the simple setup for RESTful api :
HTTP Method URL.method Controller action invoked
GET /recipes*.method* RecipesController::index()
GET /recipes/123.method RecipesController::view(123)
POST /recipes*.method* RecipesController::add()
PUT /recipes/123*.method* RecipesController::edit(123)
DELETE /recipes/123.method RecipesController::delete(123)
POST /recipes/123*.method* RecipesController::edit(123)
GET /recipes/test.json RecipesController::view(123)
name: "Action RecipesController::test() could not be found."
"/myproject/recipes/test.json" // doesn't work
"/myproject/recipes/123.json" // works
Well, reading the API for that piece of code, the value passed before the dot is matched automatically to an
UUID. Right in that API there's the params definitions
'id' - The regular expression fragment to use when matching IDs. By default, matches integer values and UUIDs.
mapResources does is simply add a lot of
Router::connect with some pre-established options (that basically has the form of :controller/:action/:id).
So, if the rule is to match ids (that cake considers to be ints) to a regular expression, clearly your string isn't passing that validation. So the
Router skips that
connect rule and goes to the other, until one matches. And the one that matches is in the form of :controller/:action.extension (probably). That's why you're getting that error,
test is clearly not intended to be an action.
Luckily, one of that options that
mapResourcesgives for customizing is the rule to match the
To add the option of strings as "ids" (since that's the only variable the REST actions are going to receive if you add the connection routes with
mapResources), change the regex that validates that rule like this
or whatever rule you want to make (I'm bad with regex, so try to adjust it to what you need).
Take a look at the docs of the API to see what other options you can add.
Keep in mind that
mapResources is there to make your life easier, so if you need more complicated routes with more params or something extra, consider forgetting about
mapResources and constructing the routes yourself (like it says in the bottom of the page of the link you provided).