-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
I have a class that has a defined scope:
class Reward scope :with_type, proc{|x| where(:_type => ( x == 'Reward' ? {'$ne' => 'SubReward'} : x ) ) } scope :with_person, proc{|x| where(:person_id => Moped::BSON::ObjectId(x.to_param))} end
Which has problems executing the scope when I call it through an association:
object.rewards.with_type("Reward")
Or when I chain it after another scope:
Reward.with_person(person).with_type("Reward")
Both of these cases give me this error:
NoMethodError: undefined method `update_values' for "Reward":String
But works when I call it first on the class:
Reward.with_type("Reward").with_person(person)
Any ideas on why this might happen? I thought it might have to do with calling it on the class vs calling it on a Mongoid enumerable or Mongoid criteria?