rails上的ruby-在rails3中的application_controller上使用number_with_pr



我确实添加了require 'action_view'&include ActionView::Helpers::NumberHelper

class ApplicationController < ActionController::Base
  require 'action_view'
  include ActionView::Helpers::NumberHelper

当我在=>def self.form_price formatted_price, total, total_till 中调用它时

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

获取此消息:

.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)
ActionController::Base.helpers.number_with_precision(total, :precision => 2, :delimiter => ',')

尝试使用类似的东西:

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

请参阅点击此处

相关内容

  • 没有找到相关文章

最新更新