Where in Rails should I modify a base class?

ruby-on-rails

Solution

My inclination would be to simply stick this into `config/initializers/fixnum.rb`. Rails will automatically pick this up during the startup process, so it should be available in the actual app, tests, etc. If you end up using this in several Rails projects, a plugin might be a good choice, too.

Problem

I want to change Fixnum to include the a "weekend_days" method: ``` class Fixnum def weekend_days //get correct days end end ``` I want this available in my controllers and models? Obviously, I also need it to work in my tests. Where is the "rails" appropriate place to put this?

Original source