and a model
Contact
with attributes
first_name and last_name
The Models are associated like this:
Contact belongs_to Company
Company has_many Contacts
I wish to make a search field into which I can type a portion of either the contact's first name, the contact's last name or the company name.
This works:
@contacts = Contact.company_name_like(params[:search])
This works:
@contacts = Contact.first_name_or_last_name_like(params[:search])
This does NOT work:
@contacts = Contact.company_name_or_first_name_or_last_name_like(params[:search])
It returns this error:
"The condition 'company_name' is not a valid condition, we could not find any scopes that match this."
Evidently the scope company_name works by itself but not in combination with the other two. And the other two work, but not with company_name. I can only assume this has to do with the association and I am missing something obvious. Can anyone point out how to do it correctly?
The last example (company_name_or_first_name_or_last_name_like) worked in an earlier version of my app, when company was an attribute of Contact. When I made Company a separate model it stopped working.
I believe I have the current version of binarylogic-searchlogic. Rails version is 2.3.2, in development mode with standard sqlite database.
given a model Company with attribute name
and a model Contact with attributes first_name and last_name
The Models are associated like this: Contact belongs_to Company Company has_many Contacts
I wish to make a search field into which I can type a portion of either the contact's first name, the contact's last name or the company name.
This works: @contacts = Contact.company_name_like(params[:search])
This works: @contacts = Contact.first_name_or_last_name_like(params[:search])
This does NOT work: @contacts = Contact.company_name_or_first_name_or_last_name_like(params[:search]) It returns this error: "The condition 'company_name' is not a valid condition, we could not find any scopes that match this."
Evidently the scope company_name works by itself but not in combination with the other two. And the other two work, but not with company_name. I can only assume this has to do with the association and I am missing something obvious. Can anyone point out how to do it correctly?
The last example (company_name_or_first_name_or_last_name_like) worked in an earlier version of my app, when company was an attribute of Contact. When I made Company a separate model it stopped working.
I believe I have the current version of binarylogic-searchlogic. Rails version is 2.3.2, in development mode with standard sqlite database.
Thank you.