Forum: Ruby on Rails Auto complete onclick

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0e92b0784ab5d0f2456728fd1909f918?d=identicon&s=25 Rodrigo Felix (Guest)
on 2009-05-26 02:35
(Received via mailing list)
I'd like to know how I can put the id in a field when the user clicks on
an
autocomplete item. I have a field with autocomplete where I wanna show
the
name of the user but save on the database the id. My code is the
following
one:

<%= text_field_with_auto_complete :user_id, :name, {:size => 15}, {:url
=>
users_path, :method => :get, :param_name => 'search'}  %>

Thanks in advance

--
*Rodrigo Felix*
Web Developer
SCJP
Fac81a9d95c81d817a2debb6f717f3ac?d=identicon&s=25 Sazima (Guest)
on 2009-05-26 23:55
(Received via mailing list)
Rodrigo,

You can either use a hidden field for the ID or follow the approach
covered by Ryan Bates in the following railscast:

http://railscasts.com/episodes/102-auto-complete-association

Cheers, Sazima

On May 25, 9:34 pm, Rodrigo Felix <rodrigofelixdealme...@gmail.com>
This topic is locked and can not be replied to.