Controller
can()
Signature
Section titled “Signature”can() — returns boolean
Available in: controller
Category: Authorization Functions
Description
Section titled “Description”Boolean policy check for conditionals and views (views run in the
controller’s variables scope, so can() is available in templates
automatically):
<cfif can(“update”, post)>##linkTo(text=“Edit”, route=“editPost”, key=post.id)##
Returns false (deny) for a guest, for an empty record, and for a policy
method that does not return boolean true. A missing method throws
Wheels.Policy.UnknownAction. A missing policy class still throws
Wheels.Policy.NotDefined in development/testing so typos fail loud; in
production it returns false.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
action | string | yes | — | The policy method to check. |
record | any | no | — | The model instance (or model class / model name string) to check against. Empty string denies. |