2

See this question. An answer points out that you can include ActionView::Helpers::NumberHelper in order to get the number_with_precision method to work in your controllers. This is also described as a bad practice. I am working on exporting data to excel which is why I need it my controller (or some non-view file). Is there a way to get comma delimiters and decimal places on my numbers generated in the controller without having to include the actionview numberhelper?

Community
  • 1
  • 1
John
  • 13,125
  • 14
  • 52
  • 73

1 Answers1

1

Starting in Rails 3, you can use view_context.number_with_precision to use the view helper from the controller.

Found it here: http://wowkhmer.com/2011/09/09/use-view-helper-methods-in-rails-3-controller/

akurtser
  • 762
  • 6
  • 11