Configuration
delete()
Signature
Section titled “Signature”delete() — returns struct
Available in: mapper
Category: Routing
Description
Section titled “Description”Create a route that matches a URL requiring an HTTP DELETE method. We recommend using this matcher to expose actions that delete database records.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | no | — | Camel-case name of route to reference when build links and form actions (e.g., blogPost). |
pattern | string | no | — | Overrides the URL pattern that will match the route. The default value is a dasherized version of name (e.g., a name of blogPost generates a pattern of blog-post). |
to | string | no | — | Set controller##action combination to map the route to. You may use either this argument or a combination of controller and action. |
controller | string | no | — | Map the route to a given controller. This must be passed along with the action argument. |
action | string | no | — | Map the route to a given action within the controller. This must be passed along with the controller argument. |
package | string | no | — | Indicates a subfolder that the controller will be referenced from (but not added to the URL pattern). For example, if you set this to admin, the controller will be located at admin/YourController.cfc, but the URL path will not contain admin/. |
on | string | no | — | If this route is within a nested resource, you can set this argument to member or collection. A member route contains a reference to the resource’s key, while a collection route does not. |
Examples
Section titled “Examples”<cfscript>
mapper()
// Route name: articleReview
// Example URL: /articles/987/reviews/12542
// Controller: Reviews
// Action: delete
.delete(name="articleReview", pattern="articles/[articleKey]/reviews/[key]", to="reviews##delete")
// Route name: cookedBooks
// Example URL: /cooked-books
// Controller: CookedBooks
// Action: delete
.delete(name="cookedBooks", controller="cookedBooks", action="delete")
// Route name: logout
// Example URL: /logout
// Controller: Sessions
// Action: delete
.delete(name="logout", to="sessions##delete")
// Route name: clientsStatus
// Example URL: /statuses/4918
// Controller: clients.Statuses
// Action: delete
.delete(name="statuses", to="statuses##delete", package="clients")
// Route name: blogComment
// Example URL: /comments/5432
// Controller: blog.Comments
// Action: delete
.delete(
name="comment",
pattern="comments/[key]",
to="comments##delete",
package="blog"
)
.end();
</cfscript>