Module: Redmine::SudoMode::Helper

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

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



49
50
51
52
53
54
55
56
57
# File 'lib/redmine/sudo_mode.rb', line 49

def hash_to_hidden_fields(hash)
  cleaned_hash = hash.to_unsafe_h.compact
  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