Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2758

rake db:mongoid:create_indexes is forcing class names

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.20
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      MONGOID: Attempted to constantize EasyUri, trying without namespacing.
      rake aborted!
      Expected /Users/klemanski/.../app/models/easy_uri.rb to define EasyUri
      

      My class is EasyURI, it's not Mongoid model.

      My workaround is config/intializers/patch_mongoid.rb:

      require 'rails/mongoid'
      
      module DetermineModelPatch
        def self.included(base)
          class << base
            alias original_determine_model determine_model
      
            def determine_model(*args)
              original_determine_model(*args)
            rescue NameError, LoadError => ex
              nil
            end
          end
        end
      end
      
      Rails::Mongoid.__send__(:include, DetermineModelPatch)
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            kml kml
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: