Reputation: 211
I have a basic search that is not working and I dont understand why.
In my model I have this
def self.search(search)
if search
search_condition = "%" + search + "%"
find(:all, :conditions => ['jobTitle LIKE ? OR jobDescription LIKE ?', search_condition, search_condition])
end
end
A parameter does get passed to it then an error comes up:
PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "all" LINE 1: ...ngs".* FROM "postings" WHERE "postings"."id" IN ('all', '--... ^ : SELECT "postings".* FROM "postings" WHERE "postings"."id" IN ('all', '--- :conditions: - jobTitle LIKE ? OR jobDescription LIKE ? - "%drew%" - "%drew%" ')
Am I doing something wrong?
Upvotes: 2
Views: 112
Reputation: 24367
You are using outdated syntax for find
. Use where
instead:
def self.search(search)
if search
search_condition = "%" + search + "%"
where(['jobTitle LIKE ? OR jobDescription LIKE ?', search_condition, search_condition])
end
end
Upvotes: 2