Syntax for number_with_precision


#1

I normally use number_with_precision in my views and I’ve never had a
problem.

Now however, I need to use it in my controller because my Ajax method is
calling the controller and the controller will return values to it which
will be displayed in the span of my html document.

In short, what am I doing wrong in the statement below? I need the ‘bid’
to be formatted with precision before it is converted to a string.
Please note that bid_counter.bid returns a decimal number.

@bids.each do |bid_counter|
mybid = number_with_precision(bid_counter.bid,2)
bidhtml += “

”+ bid_counter.user.company_name +
“ ” + bid_counter.ad_title + “ $” + mybid.to_s +
“ ”

end