Common issues when overloading code from plugins

If you try to overload models like this:

require "user" 

  class User < ActiveRecord::Base
    def your_new_method()
      # anything
    end
  end

…you will encounter problems in development mode. This is because you have circumvented Rails’ dependency mechanism with the explicit require, which will produce a User class that Rails has not marked as reloadable.

If you choose to use this style of overriding, you must use require_dependency rather than require to inform Rails that you are loading the class:

require_dependency "user"

  class User < ActiveRecord::Base
    def your_new_method()
      # anything
    end
  end