Question

Contact belongs_to status_contacts

I only want those Contacts where no value has been assigned.

I installed the searchlogic plugin.

I tried:

contacts = Contact.status_contact_null

And got an error.

How can I get a full sense of how to use associations with searchlogic, and how can I use it for this particular search?

Was it helpful?

Solution

Contact.status_contact_id_is(nil)

should generate SQL that looks like this:

SELECT * FROM `contacts` WHERE (contacts.status_contact_id IS NULL)

Searchlogic substitutes Ruby's nil for SQL's null.

You can do the reverse with ne (not equal)

Contact.status_contact_id_ne(nil)

There are a bunch of good examples on the github page for Searchlogic

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top