-
Notifications
You must be signed in to change notification settings - Fork 178
How To: Disable Default Actions
Seoung Ho Jeong edited this page Jun 29, 2024
·
2 revisions
There are 7 default actions in Trestle:
- index: Displays a list of resources.
- show: Displays a single resource.
- new: Displays a form for creating a new resource.
- create: Handles the creation of a new resource.
- edit: Displays a form for editing an existing resource.
- update: Handles the update of an existing resource.
- destroy: Handles the deletion of a resource.
You can customize these actions or remove them as needed. For example, in the users_admin.rb
file, the :new
and :create
actions are removed:
Trestle.resource(:users, model: User, scope: Auth) do
remove_action :new, :create
# ... existing code ...
end
This customization allows you to tailor the admin interface to your specific requirements.
You can also set a resource to be read-only by using the readonly: true option. This will only enable the index and show actions:
Trestle.resource(:name, readonly: true) do
# ... existing code ...
end
When you set a resource as read-only, the new
, create
, edit
, update
, and destroy
actions are automatically disabled. This is useful for resources that should not be modified through the admin interface.