# Problem with Auto Complete

**URL:** <https://www.ruby-forum.com/t/problem-with-auto-complete/125087>\
**Category:** Deployment\
**Created:** [January 5, 2008, 6:13am UTC](https://www.ruby-forum.com/t/problem-with-auto-complete/125087 "2008-01-05T06:13:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Damien\_Hunter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a3d4f5/32.png) [@Damien\_Hunter](https://www.ruby-forum.com/u/Damien_Hunter)\
**Post date:** [January 5, 2008, 6:13am UTC](https://www.ruby-forum.com/t/problem-with-auto-complete/125087/1 "2008-01-05T06:13:35Z")

</div>

I tried posting this in the Ruby on Rails talk group but haven’t been  
able to get a decent reply. Sorry if this isn’t the appropriate place  
to be posting this (if someone could tell me where I can post it, I’d  
be more than happy to move it).

I can’t get the autocomplete feature of [script.aculo.us](http://script.aculo.us) to work. I  
have tried every guide I could find and several books to no avail.

As you can probably tell from the code, I’m new to this and just used  
the scaffolding feature to setup a framework I was planning on  
altering. Things I’ve tried so far to no avail are removing the  
auto\_complete function from the controller and removing the  
javascript\_include\_tag from the view. Regardless of those changes,  
when I type the first letters of a valid name into the  
text\_field\_with\_auto\_complete it does not give me any suggestions. Any  
help would be most appreciated!

Below are excerpts from my controller and my view file:

##########################  
#ErrorsController  
##########################  
class ErrorsController \< ApplicationController  
auto\_complete\_for :error, :name

# GET /errors

# GET /errors.xml

def index  
@errors = Error.find(:all)  
respond\_to do |format|  
format.html # index.html.erb  
format.xml { render :xml =\> @errors }  
end  
end

# GET /errors/1

# GET /errors/1.xml

def show  
@error = Error.find(params[:id])

```
respond_to do |format|
  format.html # show.html.erb
  format.xml { render :xml => @error }
end

```

end

# GET /errors/new

# GET /errors/new.xml

def new  
@error = Error.new

```
respond_to do |format|
  format.html # new.html.erb
  format.xml { render :xml => @error }
end

```

end

# GET /errors/1/edit

def edit  
@error = Error.find(params[:id])  
end

# POST /errors

# POST /errors.xml

def create  
@error = Error.new(params[:error])

```
respond_to do |format|
  if @error.save
    flash[:notice] = 'Error was successfully created.'
    format.html { redirect_to(@error) }
    format.xml { render :xml => @error, :status

```

=\> :created, :location =\> @error }  
else  
format.html { render :action =\> “new” }  
format.xml { render :xml =\> @error.errors, :status  
=\> :unprocessable\_entity }  
end  
end  
end

# PUT /errors/1

# PUT /errors/1.xml

def update  
@error = Error.find(params[:id])

```
respond_to do |format|
  if @error.update_attributes(params[:error])
    flash[:notice] = 'Error was successfully updated.'
    format.html { redirect_to(@error) }
    format.xml { head :ok }
  else
    format.html { render :action => "edit" }
    format.xml { render :xml => @error.errors, :status

```

=\> :unprocessable\_entity }  
end  
end  
end

# DELETE /errors/1

# DELETE /errors/1.xml

def destroy  
@error = Error.find(params[:id])  
@error.destroy

```
respond_to do |format|
  format.html { redirect_to(errors_url) }
  format.xml { head :ok }
end

```

end

end  
#######################  
#index.html.erb  
#######################

# Listing errors
\<%= javascript\_include\_tag :defaults %\> \<%= text\_field\_with\_auto\_complete :error, :name %\> \<% for error in @errors %\> \<% end %\>

| Name | Description | Solution |
| --- | --- | --- |
| \<%=h error.name %\> | \<%=h error.description %\> | \<%=h error.solution %\> | \<%= link\_to 'Show', error %\> | \<%= link\_to 'Edit', edit\_error\_path(error) %\> | \<%= link\_to 'Destroy', error, :confirm =\> 'Are you sure?', :method =\> :delete %\> |

  

\<%= link\_to ‘New’, new\_error\_path %\>  
#######################
