using ActiveRecord to populate an array

You could probably just:

CURRENCIES = Currency.find(:all).map { |x| ["#{} (#{x.symbol})",] }

You almost certainly don't want to use an instance variable (@temp) where a local variable (temp) would do, but all you were really missing in your first post was the .each on the result of your find(:all)


Rob Biedenharn

For the UTF-8, are you doing:

require 'jcode'

Then this should work:
CURRENCIES = Currency.find(:all).map do |x|
   [ "%s%*s %s".%([x.symbol, 4-x.symbol.jlength, '-',]), ]

look at String#% or Kernel.sprintf for the formatting details

This may not work if your UTF-8 characters are of varying display widths in your browser font anyway, but it might be close enough.


Rob Biedenharn

Rails 1.2 includes multibyte chars support: