Is there a way to have rails print out a number with commas in it?
For example, if I have a number 54000000.34, I can run <%= number.function %>, which would prin
def add_commas(numstring)
correct_idxs = (1..100).to_a.select{|n| n % 6 == 0}.map{|n| n - 1}
numstring.reverse.chars.join(",").chars.select.with_index{|x, i| i.even? || correct_idxs.include?(i)}.join.reverse
end
This was my way in ruby
Addition edit: Basically it adds all commas in between the numbers and only selects the ones where the index + 1 % 6
I figured the commas up to 100 was fine but if you want a super long number just make 100 a higher number