From fa3c3cc2efcdc098d2632ef970dc1670fc6453f3 Mon Sep 17 00:00:00 2001 From: Vladimir Rozhkov Date: Wed, 19 Jul 2017 09:57:40 +0300 Subject: [PATCH] #930 Add instructions of how to disable some actions. Add IntelliJ-generated files to .gitignore. --- .gitignore | 4 ++++ docs/customizing_dashboards.md | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.gitignore b/.gitignore index bfdbea8d14..a41b5216ca 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,7 @@ /tmp/* /spec/example_app/tmp/* pkg +*.ipr +*.iml +*.iws +.idea diff --git a/docs/customizing_dashboards.md b/docs/customizing_dashboards.md index c23e88a4d2..e4299376c4 100644 --- a/docs/customizing_dashboards.md +++ b/docs/customizing_dashboards.md @@ -157,3 +157,16 @@ end ```` [define your own]: /adding_custom_field_types + +## Customizing Actions + +To enable or disable certain actions you could override `valid_action?` method in your dashboard controller like this: + +```ruby +# disable 'edit' and 'destroy' links +def valid_action?(name, resource = resource_class) + %w[edit destroy].exclude?(name.to_s) && super +end +``` + +Action is one of `new`, `edit`, `show`, `destroy`.