# Autocomplete on edit

**URL:** <https://www.ruby-forum.com/t/autocomplete-on-edit/161849>\
**Category:** Rails\
**Created:** [March 3, 2009, 2:11am UTC](https://www.ruby-forum.com/t/autocomplete-on-edit/161849 "2009-03-03T02:11:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [March 3, 2009, 2:11am UTC](https://www.ruby-forum.com/t/autocomplete-on-edit/161849/1 "2009-03-03T02:11:33Z")

</div>

Is the normal autocomplete supposed to pull from the DB what is in the  
field when doing an edit or is there something else that needs to be  
done to get it to show up while doing an edit?

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [March 3, 2009, 5:45am UTC](https://www.ruby-forum.com/t/autocomplete-on-edit/161849/2 "2009-03-03T05:45:07Z")

</div>

On Mon, Mar 2, 2009 at 7:10 PM, Me [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is the normal autocomplete supposed to pull from the DB what is in the  
> field when doing an edit or is there something else that needs to be  
> done to get it to show up while doing an edit?

I provide a Javascript array, using this method:

def users\_list  
@users = User.find( :all, :order =\> ‘username’ )  
headers[’ content-type’] = ’ text/javascript’  
render :action =\> ‘users\_list’, :layout =\> false  
end

and this view:

var users = new Array(\<%= @users.size %\>);  
\<% @users.each\_with\_index do |user, index| -%\>  
users[\<%= index %\>] = ‘\<%= user.username %\>’;  
\<% end -%\>

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)
