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

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -