rails/rails — pull request #6414 by mcmire (2012-05-20 23:50:11+00:00)
Title: ActionView: Ensure that NumberHelper is requireable on its own

I would like to start a discussion about ensuring that every helper is requireable on its own. In my project at work, I have tests that sits outside of Rails. One of my classes uses a helper out of ActionView. I shouldn't have to require all of ActionView or ActionPack just to be able to use one method from one helper. I should be able to just require the file I need and keep going.

Unfortunately, this is not the case for NumberHelper -- if you require it and then try to use one of its methods, you get:

~~~
~/code/github/forks/rails/actionpack on ruby 1.9.3-p125-falcon (master)
$ ruby -I actionpack/lib -r action_view/helpers/number_helper -e 'h = Object.new.extend(ActionView::Helpers::NumberHelper); h.number_to_currency(2)'
/Users/elliot/code/github/forks/rails/actionpack/lib/action_view/helpers/number_helper.rb:131:in `number_to_currency': undefined method `symbolize_keys' for {}:Hash (NoMethodError)
from -e:1:in `

'
~~~

I've quickly patched NumberHelper so that this is possible. However, I imagine that some of the other helpers are this way, too, and if so I'd be happy to fix them and add tests to confirm that this works.

I appreciate how Yehuda Katz tried to keep this in mind when working on Rails 3, but it seems that this mindset has been abandoned since he left, which is a bit of a shame. What's the consensus on this issue?