Ask A Question


You’re not receiving notifications from this thread.

Autocomplete a form field

Benny Maas asked in General


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.

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 83,038+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.