Setup:
-
Install Mistiq gem
-
In your application controller:
Include the module using:
include Mistiq
Add rules that get triggered when your anomaly detector returns true. If it does, it will disable the action for the controller:
before_filter { |c| c.set_guard_rule(EVAL_FUNCTION, 'controller#action'[, strip_links]) }
strip_links is an optional boolean variable that determines whether the links for that action#controller should be stripped off or not. strip_links is true by default.
Below are the pre-defined use functions for mistiq:
#disable all the actions for controller before_filter { |c| c.disable_controller('controller'[, strip_links]) } #disable action across all controllers before_filter { |c| c.disable_action_ops('action'[, strip_links]) } #disable 'create', 'add', 'new' actions across all controllers before_filter { |c| c.disable_create_ops([strip_links]) } #disable 'edit', 'update' actions across all controllers before_filter { |c| c.disable_update_ops([strip_links]) } #disable 'destroy', 'delete', 'remove' actions across all controllers before_filter { |c| c.disable_destroy_ops([strip_links]) }
Last, after you defined the rules, add the following line to check them before your application gets rendered:
before_filter :set_guard_on