문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top