Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Autocomplete a form field

General • Asked by Benny Maas


i have the following models:
users, markets, assignments, products, sales,

a user gets an assignment, and then he should enter his sales for the assignment.

i have a sales form with the following fields:

quantity, product, price

now i want to autocomplete the product_field with the products from the product model.
only products that are in the database, no new products should get over the sales form.

Any hint how to start this?



Have you looked into collection_select? It will let you make a dropdown for the product_id on the sale form. It'll automatically load up all the Products in the database and create a dropdown for you.

Then you could do something like select2 ( on that form field to make it do autocomplete.

Hi Chris,

thanks for your reply.
I will try your suggestion.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 29,763+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.