Frank
Frank

Reputation: 23

Adding extensions to a stdlib class in a ruby on rails project

where would I place additions to stdlib classes in a rails project? Let's say something like:

class Date
  def foo
    'foo'
  end
end

I thought about the initializer folder but it somehow felt wrong. Ideas?

Upvotes: 2

Views: 146

Answers (1)

alex.zherdev
alex.zherdev

Reputation: 24164

Quite on the contrary, config/initializers is the right place to put this code. I usually create a folder there and put these extensions into separate files named by the name of the corresponding class (date.rb in your case).

Upvotes: 2

Related Questions