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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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