I would like to use to_dollar
method in my model like this:
module JobsHelper
def to_dollar(amount)
if amount < 0
number_to_cur
It is not a good practice but it works for me!
to import include ActionView::Helpers::NumberHelper in the controller. For example:
class ProveedorController < ApplicationController
include ActionView::Helpers::NumberHelper
# layout 'example'
# GET /proveedores/filtro
# GET /proveedores/filtro.json
def filtro
@proveedores = Proveedor.all
respond_to do |format|
format.html # filtro.html.erb
format.json { render json: @proveedores }
end
end
def valuacion_cartera
@total_valuacion = 0
facturas.each { |fac|
@total_valuacion = @total_valuacion + fac.SumaDeImporte
}
@total = number_to_currency(@total_valuacion, :unit => "$ ")
p '*'*80
p @total_valuacion
end
end
Hope it helps you!