Question

Using the amistad gem I can get People.all

After reviewing the documentation it looks like

People.blockades and People.blockades_by

returns the people that have blocked you and the people you have blocked

https://github.com/raw1z/amistad/wiki

Is it possible to return a query of all the people except those you have blocked and those that have blocked you? i have spent a lot of time trying to figure this out to no avail. Where you are a, and

a = People.first # or any person, really

With normal SQL one could do a not in query but I can't figure this out with rails.

What I tried

People.where(:condition => "id NOT IN #{ids.join(',')}")

ERROR

: SELECT "peoples".* FROM "peoples"  WHERE "peoples"."condition" = 'id NOT IN 11,106'
PG::UndefinedColumn: ERROR:  column peoples.condition does not exist
LINE 1: SELECT "peopless".* FROM "peopless"  WHERE "peoples"."condi...
Was it helpful?

Solution

For you query you would need something like:

People.where('id NOT IN (?)', ids)

where ids is an array of id numbers (e.g. [11,106])

Now, I don't know amistad, but you might want to try doing a simple subtraction to get your require list of people. Something like:

People.all - People.blockades - People.blockades_by
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top