Sorry to bother everyone again, but I''m trying to extend this
functionality just a little bit further before calling it a day.
def auto_complete_responder_for_contacts(value)
user = User.find(current_user.id)
@contactss = user.contacts.find(:all,
:conditions => [ ''LOWER(fullname) LIKE
?'',''%'' + value.downcase + ''%''],
:order => ''fullname ASC'',
:limit => 8)
render :partial => ''contacts'' and return
end
As this stands right now, everything works. :) What I''m trying to do is
to have it search for multiple conditions and not just the fullname
field. For instance, there is a city field in the contacts table. I
would like a user to be able to type in the city and also have it
compare against that part of the table.
Unfortunately, I can''t seem to group off the first condition so that I
can use an OR to add a new one. ( ) draws a syntax error. " " kills
the
functionality altogether. Is there another way?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
:conditions => [( ''LOWER(fullname) LIKE ?) OR (LOWER(city) LIKE ?)'',''%'' + value.downcase + ''%'',''%'' + value.downcase + ''%''] that doesn''t work? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Unfortunately not.
app/controllers/desk_controller.rb:148: syntax error, unexpected
'','',
expecting '')''
:conditions => [( ''LOWER(fullname)
LIKE
?) OR (LOWER(email) LIKE ?)'',''%'' + value.downcase +
''%'',''%'' +
value.downcase + ''%'']
^
app/controllers/desk_controller.rb:148: syntax error, unexpected
'','',
expecting '')''
:conditions => [( ''LOWER(fullname)
LIKE
?) OR (LOWER(email) LIKE ?)'',''%'' + value.downcase +
''%'',''%'' +
value.downcase + ''%'']
^
app/controllers/desk_controller.rb:148: syntax error, unexpected
'']'',
expecting '')''
:conditions => [( ''LOWER(fullname)
LIKE
?) OR (LOWER(email) LIKE ?)'',''%'' + value.downcase +
''%'',''%'' +
value.downcase + ''%'']
^
app/controllers/desk_controller.rb:149: syntax error, unexpected
'','',
expecting '')''
app/controllers/desk_controller.rb:151: syntax error, unexpected
tIDENTIFIER, expecting '']''
render :partial => ''contacts'' and return
Thorsten wrote:> :conditions => [( ''LOWER(fullname) LIKE
> ?) OR (LOWER(city) LIKE ?)'',''%'' + value.downcase
+ ''%'',''%'' +
> value.downcase + ''%'']
>
> that doesn''t work?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
That first parenthesis should probably be inside the quote. -John On Jun 28, 6:09 am, Robert Scott <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Unfortunately not. > > app/controllers/desk_controller.rb:148: syntax error, unexpected '','', > expecting '')'' > :conditions => [( ''LOWER(fullname) LIKE > ?) OR (LOWER(email) LIKE ?)'',''%'' + value.downcase + ''%'',''%'' + > value.downcase + ''%''] > ^ > app/controllers/desk_controller.rb:148: syntax error, unexpected '','', > expecting '')'' > :conditions => [( ''LOWER(fullname) LIKE > ?) OR (LOWER(email) LIKE ?)'',''%'' + value.downcase + ''%'',''%'' + > value.downcase + ''%''] > ^ > app/controllers/desk_controller.rb:148: syntax error, unexpected '']'', > expecting '')'' > :conditions => [( ''LOWER(fullname) LIKE > ?) OR (LOWER(email) LIKE ?)'',''%'' + value.downcase + ''%'',''%'' + > value.downcase + ''%''] > ^ > app/controllers/desk_controller.rb:149: syntax error, unexpected '','', > expecting '')'' > app/controllers/desk_controller.rb:151: syntax error, unexpected > tIDENTIFIER, expecting '']'' > render :partial => ''contacts'' and return > > Thorsten wrote: > > :conditions => [( ''LOWER(fullname) LIKE > > ?) OR (LOWER(city) LIKE ?)'',''%'' + value.downcase + ''%'',''%'' + > > value.downcase + ''%''] > > > that doesn''t work? > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---