Forum: Ruby on Rails Helper help - inserting delimiters

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
B965bae86df56534d608c5938266522c?d=identicon&s=25 Guðni Hilmarsson (Guest)
on 2007-04-17 14:19
(Received via mailing list)
My ruby skills are a bit underdeveloped, but I managed to whip up a
Helper that inserts a delimiter at a fixed position in a number.
Any wizards out there that can give tips on how to scale this to
accepting calls for putting a delimiter at more than 1 position?

  def insert_delimiter_at(number, pos, delimiter="-")
      number = number.to_s
      parts = []
      parts[0] =
      parts[1] = number.from(pos)
      number = parts.join delimiter
This topic is locked and can not be replied to.