Reputation: 103
row = Hash[new_hash.map { |k, v| k, v.encode("UTF-16BE", invalid: :replace, undef: :replace, replace: '?').encode("UTF-8") }]
This line in a controller causes an syntax error, but I can't find any mistakes. Can anyone figure out what's going wrong?
This is a Rails application. Ruby 2.2.0
and Rails 4.2.0
.
Upvotes: 0
Views: 502
Reputation: 51151
You forgot brackets ([]
). It should be:
row = Hash[new_hash.map{ |k, v| [k, v.encode("UTF-16BE", invalid: :replace, undef: :replace, replace: '?').encode("UTF-8")] }]
Upvotes: 2