debian-mirror-gitlab/app/helpers/safe_params_helper.rb

16 lines
430 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2018-06-27 16:04:02 +05:30
module SafeParamsHelper
2018-10-15 14:42:47 +05:30
# Rails 5.0 requires to permit `params` if they're used in url helpers.
2018-06-27 16:04:02 +05:30
# Use this helper when generating links with `params.merge(...)`
2018-12-05 23:21:45 +05:30
# rubocop: disable CodeReuse/ActiveRecord
2018-06-27 16:04:02 +05:30
def safe_params
if params.respond_to?(:permit!)
params.except(:host, :port, :protocol).permit!
else
params
end
end
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2018-06-27 16:04:02 +05:30
end