Created
September 5, 2018 18:10
-
-
Save hashedhyphen/a433d78ad6d091ffdf123355f23545aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveAdmin.register SomeModel do | |
permit_params :flag | |
module ControllerWithParamsMapping | |
MAP = { '0' => false, '1' => true } | |
def permitted_params | |
mapped_params = super | |
if mapped_params[:some_model].present? | |
mapped_params[:some_model][:flag] = MAP[mapped_params[:some_model][:flag]] | |
end | |
mapped_params | |
end | |
end | |
controller.prepend(ControllerWithParamsMapping) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment