2018-08-18 11:19:57 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-08 04:35:30 +00:00
|
|
|
module SafeParamsHelper
|
2018-04-08 05:27:27 +00: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-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-04-08 04:35:30 +00:00
|
|
|
def safe_params
|
|
|
|
if params.respond_to?(:permit!)
|
|
|
|
params.except(:host, :port, :protocol).permit!
|
|
|
|
else
|
|
|
|
params
|
|
|
|
end
|
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-04-08 04:35:30 +00:00
|
|
|
end
|