2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-08 00:35:30 -04:00
|
|
|
module SafeParamsHelper
|
2018-04-08 01:27:27 -04:00
|
|
|
# Rails 5.0 requires to permit `params` if they're used in url helpers.
|
|
|
|
# Use this helper when generating links with `params.merge(...)`
|
2018-04-08 00:35:30 -04:00
|
|
|
def safe_params
|
|
|
|
if params.respond_to?(:permit!)
|
2020-10-01 14:10:20 -04:00
|
|
|
params.except(*ActionDispatch::Routing::RouteSet::RESERVED_OPTIONS).permit!
|
2018-04-08 00:35:30 -04:00
|
|
|
else
|
|
|
|
params
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|