Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hashedhyphen/a433d78ad6d091ffdf123355f23545aa to your computer and use it in GitHub Desktop.
Save hashedhyphen/a433d78ad6d091ffdf123355f23545aa to your computer and use it in GitHub Desktop.
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