Where is the best place to add methods to the Integer class in Rails?

前端 未结 7 1085
面向向阳花
面向向阳花 2021-02-10 06:19

Where is the best place to add a method to the integer class in Rails? I\'d like to add a to_meters and to_miles methods.

7条回答
  •  不思量自难忘°
    2021-02-10 06:45

    If you were going to do this, which you shouldn't, then you would put your code into:

    config/initializers/add_methods_that_are_naughty_to_numeric.rb
    

    Rails would automatically run these for you.

提交回复
热议问题