rab
(Rob Biedenharn)
November 9, 2006, 9:31pm
1
You could probably just:
CURRENCIES = Currency.find(:all).map { |x| ["#{x.name} (#{x.symbol})", x.id] }
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
Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
rab
(Rob Biedenharn)
November 9, 2006, 10:57pm
2
For the UTF-8, are you doing:
$KCODE = 'UTF8'
require 'jcode'
Then this should work:
CURRENCIES = Currency.find(:all).map do |x|
[ "%s%*s %s".%([x.symbol, 4-x.symbol.jlength, '-', x.name]), x.id ]
end
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
Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
bitsweat
(Jeremy Daer)
November 9, 2006, 11:05pm
3
Rails 1.2 includes multibyte chars support:
x.symbol.chars.length
jeremy