views:

63

answers:

2

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?

+8  A: 

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.

Mirko Froehlich
+2  A: 

Just a plug, but I've written a plugin that adds "weekday" math to Date, Time, and Fixnum. "Weekdays" is available here: http://github.com/mdarby/weekdays

Matt Darby