ruby on rails - Is it possible to use "number_to_currency" inside a controller? -
i a, building dropdown menu in form displays list of available options , prices in form: "service - price". problem, however, doesn't can use number_to_currency inside controller. there way achieve same effect, or access number_to_currency controller? here initial effort:
@levels = [] distributorlevel.all.each |d| price = (d.price > 0) ? number_to_currency(d.price) : "free" @levels << ["#{d.name} - #{price}", d.id] end
yes, with:
view_context.number_to_currency(d.price)
or
actioncontroller::base.helpers.number_to_currency(d.price)
Comments
Post a Comment