Module: EncodingHelper

Defined in:
app/helpers/encoding_helper.rb

Instance Method Summary collapse

Instance Method Details

#to_current_encoding(value) ⇒ String

Encode value using user configuration This method assumes current_user exists

Returns:

  • (String)


7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/encoding_helper.rb', line 7

def to_current_encoding(value)
  encoded_value = nil
  if !value.nil?
    begin
      encoded_value = value.encode(current_user.encoding)
    rescue
      encoded_value = value.force_encoding(current_user.encoding)
    end
  end
  encoded_value
end