I need to pass a parameter in my text_field_with_auto_complete and am struggling to discover how to do this. I have something like this: <%= text_field_with_auto_complete ''user'', ''username'', {}, {:with => "''post=''@company_title.id"} %> but because it is in a partial that pops as a result from a remote_function_tag, I am having trouble seeing the html to know if this is even working. In any event, it is not giving me back what I want. Is there a way to pass parameters to the auto_complete_for method? Thanks, -S -- Posted via http://www.ruby-forum.com/.
Hi Shandy, On Fri, 2009-07-10 at 21:34 +0200, Shandy Nantz wrote:> I need to pass a parameter in my text_field_with_auto_completeWhat''s the parameter supposed to do? What are you trying to accomplish? Bill
bill walton wrote:> Hi Shandy, > > On Fri, 2009-07-10 at 21:34 +0200, Shandy Nantz wrote: >> I need to pass a parameter in my text_field_with_auto_complete > > What''s the parameter supposed to do? What are you trying to accomplish? > > BillWell, I have an auto_complete to get users names, and in other forms it works great. This auto_complete, however, it first asks the user to select an account and then pull all the users from that account, so the parameter that I need to pass is the id to the account to populate that list. -- Posted via http://www.ruby-forum.com/.
On Fri, 2009-07-10 at 22:08 +0200, Shandy Nantz wrote:> bill walton wrote: > > Hi Shandy, > > > > On Fri, 2009-07-10 at 21:34 +0200, Shandy Nantz wrote: > >> I need to pass a parameter in my text_field_with_auto_complete > > > > What''s the parameter supposed to do? What are you trying to accomplish? > > > > Bill > > Well, I have an auto_complete to get users names, and in other forms it > works great. This auto_complete, however, it first asks the user to > select an account and then pull all the users from that account, so the > parameter that I need to pass is the id to the account to populate that > list.Ah. Ok. It''s been a while since I used auto_complete and haven''t tested this, but it should point you in the right general direction. First though, note that everything after the first two parameters is interpreted as elements of a hash. You don''t need the {} notation. The items that can appear in that hash are the parameters to ActiveRecord::Base#find. IIRC auto_complete just passes them through to the find. You''re wanting to supply the :conditions. The syntax may be wrong but I already warned you I haven''t tested it. ;-) <%= text_field_with_auto_complete ''user'', ''username'', :conditions => ["post = ?", @company_title.id] %> HTH, Bill