Rails plugins' initializer script, init.rb
, is currently invoked via eval
, not require
—so it inherits whatever module-space Rails calls it from. If you reopen any classes in init.rb
itself (like the will_paginate
guys quite reasonably attempted to define Hash#slice
), your changes will be made—but to the wrong module.
So, to avoid strange gotchas, consider init.rb
just a generic hook point to kick things off, and always require
in any code that's to do actual work at plugin load time.
Alternatively, you can explicitly anchor referenced classes to the top level, like ::Hash
. That's the route will_paginate
took, but I would just break out a separate file and require
it to keep things plain and clear.