Where in Rails should I change the base class?

I want to change Fixnum to include the "weekend_days" method:

class Fixnum

  def weekend_days
    //get correct days
  end

end

I want this to be available on my controllers and models? Obviously, I also need it to work in my tests.

Where are the "rails" suitable place to place?

+3
source share
2 answers

My addiction was just to put it in config/initializers/fixnum.rb. Rails will automatically pick this up during the startup process, so it should be available in a real application, tests, etc. If you end up using this in several Rails projects, it might also be a good plugin.

+8
source

, , " " Date, Time Fixnum. " " : http://github.com/mdarby/weekdays

+2

Source: https://habr.com/ru/post/1719788/


All Articles