Class name collisions

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • 2.4.1
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I have two model classes, Scheduler and Strategy. Inside Scheduler I have the following function:

      def add_strategy(role, strategy_name)
      ...
      strategy = Strategy.find_or_create_by(:name => strategy_name)
      ...
      end

      When I execute this method, I get the following error:

      undefined method `find_or_create_by' for Mongoid::Relations::Cascading::Strategy:Class (NoMethodError)

      If I execute Strategy.find_or_create_by in the console, there are no problems. For some reason, Strategy is colliding with a Mongoid defined class. I assume there is a good reason for this, so is there some alternative way of referencing my Strategy model/collection from within another Mongoid::Document model?

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

                Created:
                Updated:
                Resolved: