Clear it first to just open the Object class directly:
class Object def nil_or_empty? nil? || respond_to?(:empty?) && empty? # or even shorter: nil? || try(:empty?) end end
Secondly, pointing Rails to autoload / lib does not mean that the files in / lib will load when your application starts - it means that when using a constant that is not currently defined, Rails will look for a file in / lib that matches this constant. For example, if you referenced ObjectExtensions in the Rails application code, and it has not yet been defined somewhere, Rails would expect to find it in lib / object_extensions.rb.
Since you cannot extend the main class in / lib like this, it is better to put the main extensions in the config / initializers directory. Rails will download all the files there automatically when your application loads. So try putting the specified Object extension in config / initializers / object_extension.rb or config / initializers / extensions / object.rb or something similar, and everything should work fine.
source share