# Auto\_complete plugin

**URL:** <https://www.ruby-forum.com/t/auto-complete-plugin/191326>\
**Category:** Rails\
**Created:** [July 9, 2010, 5:21pm UTC](https://www.ruby-forum.com/t/auto-complete-plugin/191326 "2010-07-09T17:21:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mlle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eada6e/32.png) [@Mlle](https://www.ruby-forum.com/u/Mlle)\
**Post date:** [July 9, 2010, 5:21pm UTC](https://www.ruby-forum.com/t/auto-complete-plugin/191326/1 "2010-07-09T17:21:52Z")

</div>

I have a method in my controller that would apply to all fields that  
use the auto\_complete plugin

def auto\_complete\_for

```
object = params[:id].split('_')[0]
method = params[:id].split('_')[1]

table = object.to_s.camelize.constantize.table_name

object.to_s.camelize.constantize::init( @lang )
tables = object.to_s.camelize.constantize::tables

if tables.include?( "#{table}_#{method}" )

```

etc…

So in my template I have:

\<%=text\_field\_with\_auto\_complete :sample, c, {:skip\_style=\>true} %\>

but the ajax request is not right. It says

[http://localhost:3000/echantillons/auto\_complete\_for\_sample\_technique](http://localhost:3000/echantillons/auto_complete_for_sample_technique)

and the parameters are  
Parameters: {“sample”=\>{“technique”=\>“test”}}

whereas I think it should say

[http://localhost:3000/echantillons/auto\_complete\_for/sample\_technique](http://localhost:3000/echantillons/auto_complete_for/sample_technique)  
with parameters {“id”=\>{“sample\_technique”"}}

What am I doing wrong?
