Found the answer...
Conditions for auto_complete belong in the view template, e.g. <%=
text_field_with_auto_complete :customer, :customernumber, :conditions =>
''deleted_at=0'' %>
-----Original Message-----
From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-talk@googlegroups.com]On Behalf Of Nathan Leach
Sent: Wednesday, August 30, 2006 12:49 PM
To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: [Rails] Help needed on "auto_complete_for" with conditions
I have the following in a controller, where the view allows the user to enter a
partial customer number and have auto-complete provide the list of matches. It
was working fine until I added a condition (to see if it would work).
Here''s the code and the (incorrect?) SQL generated. Is this a bug or
am I going at this the wrong way? It seems like the SQL is not being generated
correctly, even though the controller is processing the condition.
Fromcontroller...
auto_complete_for :customer, :customernumber, :conditions =>
{''deleted_at='', 0}
Fromdevelopment.log...(note: my "customernumber" field is a string,
not an integer)
Processing SalesdocumentsController#auto_complete_for_customer_customernumber
(for 127.0.0.1 at 2006-08-30 12:40:56) [POST]
Session ID: d140dfc13f62b939f26e39068c91c677
Parameters:
{"action"=>"auto_complete_for_customer_customernumber",
"controller"=>"salesdocuments",
"customer"=>{"customernumber"=>"john"}}
[4;35;1mCustomer Load (0.000000) SELECT * FROM customers WHERE
(deleted_at=0) ORDER BY customernumber ASC LIMIT 10
Completed in 0.00010 (10000 reqs/sec) | Rendering: 0.00000 (0%) | DB: 0.00000
(0%) | 200 OK [
http://localhost/salesdocuments/auto_complete_for_customer_customernumber]
Any help would be appreciated.
Thanks,
Nathan
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---