# Auto\_complete\_for exists but not being found by Rails

**URL:** <https://www.ruby-forum.com/t/auto-complete-for-exists-but-not-being-found-by-rails/100279>\
**Category:** Rails\
**Created:** [July 28, 2006, 4:16am UTC](https://www.ruby-forum.com/t/auto-complete-for-exists-but-not-being-found-by-rails/100279 "2006-07-28T04:16:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [July 28, 2006, 4:16am UTC](https://www.ruby-forum.com/t/auto-complete-for-exists-but-not-being-found-by-rails/100279/1 "2006-07-28T04:16:53Z")

</div>

Anybody encounter this. I know the method exists in the auto\_complete.rb  
file in my rails installation, but it itsnt accessing it throught he  
program.

Any ideas?

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [July 28, 2006, 6:11am UTC](https://www.ruby-forum.com/t/auto-complete-for-exists-but-not-being-found-by-rails/100279/2 "2006-07-28T06:11:09Z")

</div>

Should I reinstall Rails?

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [July 28, 2006, 6:20am UTC](https://www.ruby-forum.com/t/auto-complete-for-exists-but-not-being-found-by-rails/100279/3 "2006-07-28T06:20:33Z")

</div>

On 7/28/06, Eric G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Should I reinstall Rails?
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

If your using it from the controller then it should be there.

You could always try re-installing rails. It’s a bit hard to guess  
whats  
happening with as much information as you’ve posted. Can you be a  
little  
more specific about what’s happening

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [July 28, 2006, 6:45am UTC](https://www.ruby-forum.com/t/auto-complete-for-exists-but-not-being-found-by-rails/100279/4 "2006-07-28T06:45:36Z")

</div>

Sure Daniel,

This is the controller code:

def realsignup  
auto\_complete\_for :sports, :name  
end

realsignup.rhtml is the page that gets loaded.

Here is the error I get.

“undefined method `auto\_complete\_for’ for #UserController:0x37d88a8”

Eric

Daniel ----- wrote:

> On 7/28/06, Eric G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Should I reinstall Rails?
> > 
> > –  
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> > 
> > * * *
> > 
> > Rails mailing list  
> > removed\_email\_address@domain.invalid  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [July 28, 2006, 8:18am UTC](https://www.ruby-forum.com/t/auto-complete-for-exists-but-not-being-found-by-rails/100279/5 "2006-07-28T08:18:48Z")

</div>

I have used the auto complete and its working for me…

The way I did it was

```
In the views

   1. Include the default javascript in the .rhtml file
  		<%= javascript_include_tag :defaults %>

   2. Where ever u wanna do the autocomplete include this tag

        <%= text_field_with_auto_complete :movie, :movie_name %>

        book and the book_name are the name of the textbox
        So u can access the value of the textbox with
        params[:movie]['movie_name'] in the controller.

       Thats all in the views...

Now in the controller

  1. Define a method named "auto_complete_for_book_book_name"
       Remember this method should be there in the same controller 

```

as that of the view page.  
I tried the way u did b4, and got the same error. So I did  
this way…

```
       	def auto_complete_for_book_book_name
		book_search = params[:movie][:movie_name]
		@books = Book.find(:all,
				   :conditions => [ 'LOWER(book_name) LIKE ?',book_search.downcase 

```

- ‘%’ ],  
:order =\> ‘book\_name ASC’)  
render :partial =\> ‘/views/all\_views’  
end

Thats it…

An example is given in the [script.aculo.us](http://script.aculo.us). Follow this link and find  
it…

[http://demo.script.aculo.us/ajax/autocompleter\_customized](http://demo.script.aculo.us/ajax/autocompleter_customized)

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [July 28, 2006, 9:52am UTC](https://www.ruby-forum.com/t/auto-complete-for-exists-but-not-being-found-by-rails/100279/6 "2006-07-28T09:52:02Z")

</div>

Hey Anand,

Thanks for the advice, I got it to work kinda.

Its querying my database, however when I click on one of the items, its  
shows up in the text field with a top margin and extra spaces on both  
sides of the entry.

Basically, when it shows up in my text field, i can only see the very  
top of the word because the whole entry is shifted down some. I have to  
drag within the text field to reveal the word.

Overall, it takes up like 3 lines with the word in the middle line, so  
you cant even see the word unless you drag down inside the text field.  
Do you know what could be wrong?

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [July 28, 2006, 12:37pm UTC](https://www.ruby-forum.com/t/auto-complete-for-exists-but-not-being-found-by-rails/100279/7 "2006-07-28T12:37:36Z")

</div>

Hi,  
I am a bit confused what ur problem is???  
if u dont have any probs, can u just take a screenshot of it and send me  
so that I can understand it properly…

my mai id is removed\_email\_address@domain.invalid

Regards,  
Anand

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [July 28, 2006, 1:07pm UTC](https://www.ruby-forum.com/t/auto-complete-for-exists-but-not-being-found-by-rails/100279/8 "2006-07-28T13:07:50Z")

</div>

Ananda, I got it working, basically, in the partial for the list, there  
were spaces

in between the div and li tags…

thanks for all your help…
