Overriding/Modifying Rails Class (ActiveResource)

耗尽温柔 提交于 2019-12-02 07:25:05

First of all, this is an issue you should report to Rails' bugtracker: https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/

When I have to hotfix minor things like these, I usually create an initializer file in RAILS_ROOT/config/initializers and reopen the class I intend to fix.

class ActiveResource::Base
  # your fix goes here
end

This is called monkey patching and is somewhat controversial. But I personally consider it quite brutal to introduce a new level into the inheritance hierarchy that has no semantical meaning to my code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!