Forum: Ruby on Rails auto_complete_with_index_for

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8ed6d55dddf47e0974bac833f08e4390?d=identicon&s=25 Ian Harding (Guest)
on 2006-01-30 17:49
(Received via mailing list)
I have a crude hack to allow auto_complete to work with indexed text
fields.  I needed it for a timecard entry form with an arbtirary
number of records which can be added/changed/delete willy-nilly by
users.  One of the fields is a perfect candidate for autocomplete
since it references a database object with a large number of choices
and long descriptions.  Using a select list is extremely ugly in this
case.

I copied the code for text_field_with_auto_complete out of

/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/helpers/java_script_macros_helper.rb

and hacked it, putting the result in

app/helpers/application_helper.rb

as text_field_with_index_auto_complete.  All it does differently is
not output the index in the name of the method to be called.

I copied the code for auto_complete_for out of

/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/macros/auto_complete.rb

and pasted it right back in as auto_complete_with_index_for.  It just
ignores the index in the parameter.  Everything else is the same.

I will probably submit a bug report and a patch eventually, but in the
meantime, I would like to know if I can put the new
auto_complete_with_index_for somewhere local to my application, or
does it have to live in the rails source?

Thanks!

- Ian
8ed6d55dddf47e0974bac833f08e4390?d=identicon&s=25 Ian Harding (Guest)
on 2006-01-31 18:58
(Received via mailing list)
Hey, answered my own question.  I copied the relevant bits of
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/macros/auto_complete.rb
into environment.rb.  Cool beans.

If anyone wants magic auto completion for indexed fields (a la render
:partial) then let me know.

On 1/30/06, Ian Harding <harding.ian@gmail.com> wrote:
> 
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/helpers/java_script_macros_helper.rb
> 
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/macros/auto_complete.rb
>
> - Ian
>


--
"Her faults were those of her race and sex; her virtues were her own.
Farewell, and if for ever - "

-- "Travels with a Donkey in the Cevennes" by Robert Louis Stevenson
This topic is locked and can not be replied to.