Module: Redmine::SudoMode::Helper

Included in:
ApplicationHelper
Defined in:
lib/redmine/sudo_mode.rb

Overview

Since:

  • 3.1.0

Instance Method Summary collapse

Instance Method Details

#hash_to_hidden_fields(hash) ⇒ Object

Represents params data from hash as hidden fields

taken from github.com/brianhempel/hash_to_hidden_fields



33
34
35
36
37
38
39
40
41
# File 'lib/redmine/sudo_mode.rb', line 33

def hash_to_hidden_fields(hash)
  cleaned_hash = hash.reject { |k, v| v.nil? }
  pairs = cleaned_hash.to_query.split(Rack::Utils::DEFAULT_SEP)
  tags = pairs.map do |pair|
    key, value = pair.split('=', 2).map { |str| Rack::Utils.unescape(str) }
    hidden_field_tag(key, value)
  end
  tags.join("\n").html_safe
end