Forum: Ruby on Rails ASCII character in select box

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cow (Guest)
on 2007-06-14 15:35
(Received via mailing list)
Hi all,

I've been searching for hours trying to find a way to display the euro
symbol using the select method. My code is as follows:

addresses = @cart.company.delivery_addresses.map {|a| [a.description,
a.id]}
addresses << ["Other address &euro; 5,00",0]
select "delivery_address", "address_id", addresses

The problem is that rails makes the input html save, does anyone have
an idea how to accomplice this?
Bob S. (Guest)
on 2007-06-14 18:22
(Received via mailing list)
On 6/14/07, Cow <removed_email_address@domain.invalid> wrote:
>
> The problem is that rails makes the input html save, does anyone have
> an idea how to accomplice this?

So you need to include the character directly. Assuming your output
encoding is UTF-8 (default in latest Rails), you can do something
like:

   euro = [8364].pack('U')
   addresses << ["Other address #{euro} 5,00",0]

I don't know if Ruby accepts UTF-8 source code, but if it does, you
could just insert the character directly (if your editor can do that).
Cow (Guest)
on 2007-06-14 19:10
(Received via mailing list)
Cool, works great (both the direct and indirect method).

Thanks for the quick reply (and the answer).
This topic is locked and can not be replied to.