开发者

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

开发者 https://www.devze.com 2023-01-02 22:46 出处:网络
where would I place additions to stdlib classes in a rails project? Let\'s say somethi开发者_开发问答ng like:

where would I place additions to stdlib classes in a rails project? Let's say somethi开发者_开发问答ng like:

class Date
  def foo
    'foo'
  end
end

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


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消