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



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

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