Forum: Ruby on Rails auto_complete on steroids

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.
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-26 05:47
(Received via mailing list)
I am trying to get more out of auto_complete than it apparently was
designed to deliver.

My problems seem to be two fold.

1 - I use aggregations on
names... :first_name, :middle_initial, :last_name and then aggregate
them using a composed_of :wholename thing

auto_complete_for seems to be wired to only use table columns directly
and gags on the aggregate form.

2 - foreign table columns - auto_complete_for seems to be unusable for
obtaining matching values from a column in another table but I haven't
fully explored this since I was trying to get the aggregation per above
and finally stayed within table and found that aggregations didn't work
period and when I checked out the api, I sort of knew why.

So I ask...is there an auto_complete plugin/gem that I can't seem to
find that is like auto_complete on steroids?

Thanks

Craig
Ac1da5d66d51a1c3b843221032247b30?d=identicon&s=25 Eric Goodwin (Guest)
on 2006-02-26 06:14
(Received via mailing list)
Hi Craig,
I don't know of any 'auto_complete on steroids' but you can do alot more
than the defaults if you write your own sql.
If you take a look at Amy Hoy's post of auto-complete she shows how to
do
this in the 'roll your own' section.

http://www.slash7.com/articles/2005/08/13/ajaxarif...

If you do that you should be able to use CONCAT in your sql statement to
concat a few columns together. After that you'd probably want to get rid
of the white space from your query because after the concat, you won't
have any white space between firstname,middle and last. (ie.
EricAGoodwin
)
Check out the example below.

SELECT * FROM users WHERE CONCAT(firstname,middlename,lastname) =
#{params[:q].gsub(/\s/,'')};

You should be able to write your own sql for the foreign tables columns
as
well.

Cheers,
Eric Goodwin
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-26 06:23
(Received via mailing list)
On Sun, 2006-02-26 at 05:10 +0000, Eric Goodwin wrote:
> of the white space from your query because after the concat, you won't
> have any white space between firstname,middle and last. (ie. EricAGoodwin
> )
> Check out the example below.
>
> SELECT * FROM users WHERE CONCAT(firstname,middlename,lastname) =
> #{params[:q].gsub(/\s/,'')};
>
> You should be able to write your own sql for the foreign tables columns as
> well.
----
yep - that looks like what I want to do.

OK - makes for some excitement on an otherwise dull Saturday night.

;-)

Thanks

Craig
This topic is locked and can not be replied to.