I encountered a problem today, in that the number_to_human helper has a defect where it spits out an error when passed any number bigger than 0 and less than 1. eg number_to_human(0.2) gives "nil can''t be coerced into fixnum" So, I found this patch: https://github.com/rails/rails/commit/7c8a5f5759a0c63945d133280fb78deaa86b65b9 Now to apply it, I had to create a file: lib/number_helper_overrides and put the override code in there: module ActionView module Helpers module NumberHelper def number_to_human(number, options = {}) #the code in here bla bla end end end end then in environment.rb I put: require "number_helper_overrides" Is this the proper way to override in rails 3? If so, then should I really need to put the "require" statement into the environment.rb file? I already have the autoload path set to load file from the lib directory? thanks, Lee -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/HKovAngcdhQJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
anyone? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/MdZB46PPVYIJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Oct 26, 2011 at 10:23 PM, cipher_neo <l33z3r-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I encountered a problem today, in that the number_to_human helper has a > defect where it spits out an error when passed any number bigger than 0 and > less than 1. > > eg number_to_human(0.2) gives "nil can''t be coerced into fixnum" > > So, I found this patch: > > > https://github.com/rails/rails/commit/7c8a5f5759a0c63945d133280fb78deaa86b65b9 > > Now to apply it, I had to create a file: lib/number_helper_overrides and > put the override code in there: > > module ActionView > module Helpers > module NumberHelper > def number_to_human(number, options = {}) > #the code in here bla bla > end > end > end > end > >then in environment.rb I put:> > require "number_helper_overrides" > > Is this the proper way to override in rails 3? > > If so, then should I really need to put the "require" statement into the > environment.rb file? > I already have the autoload path set to load file from the lib directory? > >Have you tried putting it in config/initializers/? You won''t need the require statement if you put it there.> thanks, > > Lee > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/HKovAngcdhQJ. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
yes, that seems to have done the job, thanks! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/OU2B4X8HpiQJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.