Tintin81
Tintin81

Reputation: 10207

Best way to look up currency units in Ruby on Rails?

In my Ruby on Rails application I have this:

module Constants

  CURRENCIES = { 
    "EUR" => "€",
    "USD" => "$",
    "GBP" => "£"
  }

end

This works but is causing me some trouble because the HTML-entities can't be escaped in certain situations, e.g. when generating .csv or .pdf files.

It would be better to store the currency symbols like this:

module Constants

  CURRENCIES = { 
    "EUR" => "€",
    "USD" => "$",
    "GBP" => "£"
  }

end

However, when I do that I get this nasty error from Rails: We're sorry, but something went wrong.

What am I missing here?

Thanks for any help.

Upvotes: 0

Views: 357

Answers (1)

BvuRVKyUVlViVIc7
BvuRVKyUVlViVIc7

Reputation: 11811

Add

# -*- coding: utf-8 -*-

at the top of your file.

Upvotes: 4

Related Questions