1

I have two collections in my mongoDB of my Ruby on Rails Project, One with motions and an other one with actors. The motions have an attribute actor that contains the name of the actor and through which you can find him. I know want to find all the motions that belong to an actor of a specific gender. The code I use is the following.

found = Motion.all
found.each do |x|
    n = x.actor
    a = actors.where(:name => n).first
    if a.gender != search_gender
      found = found.where.not(:name => n)
    end
  end

But i always get the Error

wrong number of arguments (0 for 1)

it's supposed to be in this line:

found = found.where.not(:name => n)

but I dont really know what i did wrong here. Can anyone tell me or does anyone know a different way i could do this? I am not too familiar with rails so it could be a pretty stupid mistake. any help appreciated.

Ipomea
  • 121
  • 2
  • 16

1 Answers1

2

It's because the where method needs at least one argument, but you are not passing anything.

Here you can use not_in query:

found = found.not_in(:name => n)

This stack overflow question might help you.

Community
  • 1
  • 1
Narasimha Reddy - Geeker
  • 3,510
  • 2
  • 18
  • 23