-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: 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?