From 3ea91edd1c688fa2e5eb3f7875f716ae43212ab7 Mon Sep 17 00:00:00 2001 From: Pablo Brasero Date: Thu, 5 Dec 2019 16:04:58 +0000 Subject: [PATCH] Document `resource_params` --- .../dashboard/templates/controller.rb.erb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/generators/administrate/dashboard/templates/controller.rb.erb b/lib/generators/administrate/dashboard/templates/controller.rb.erb index ac192f6035..cfb19fc731 100644 --- a/lib/generators/administrate/dashboard/templates/controller.rb.erb +++ b/lib/generators/administrate/dashboard/templates/controller.rb.erb @@ -29,6 +29,18 @@ module <%= namespace.classify %> # end # end + # Override `resource_params` if you want to transform the submitted + # data before it's persisted. For example, the following would turn all + # empty values into nil values: + # + # def resource_params + # params.require(resource_name) + # .permit(dashboard_class::FORM_ATTRIBUTES) + # .transform_values do |value| + # value == "" ? nil : value + # end + # end + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end