whitesiroi
whitesiroi

Reputation: 2843

Using number_with_precision on application_controller in rails3

I did add require 'action_view' & include ActionView::Helpers::NumberHelper

class ApplicationController < ActionController::Base

  require 'action_view'
  include ActionView::Helpers::NumberHelper

And, when I call it in my => def self.form_price formatted_price, total, total_till

puts number_with_precision(total, :precision => 2, :delimiter => ',')

Get this message:

.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.13/lib/rails/commands/runner.rb:53:in `eval': undefined method `number_with_precision' for ApplicationController:Class (NoMethodError)

Upvotes: 0

Views: 1838

Answers (2)

Jenorish
Jenorish

Reputation: 1714

Try using something like this:

view_context.number_with_precision(total, :precision => 2, :delimiter => ',')

Please refer click here

Upvotes: 1

whitesiroi
whitesiroi

Reputation: 2843

ActionController::Base.helpers.number_with_precision(total, :precision => 2, :delimiter => ',')

Upvotes: 2

Related Questions