Skip to content

Controller

can()

can() — returns boolean

Available in: controller Category: Authorization Functions

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.

NameTypeRequiredDefaultDescription
actionstringyes—The policy method to check.
recordanyno—The model instance (or model class / model name string) to check against. Empty string denies.