Ask A Question


You’re not receiving notifications from this thread.

[Administrate] Autocomplete on 'foo: Field::BelongsTo'

Nelson Casanova asked in Gems / Libraries


I'm currently doing some tests using Administrate to see if the functionality can be shaped in a way that is convenient for me... Some things have been quite easy and for the most part satisfactory, like arranging things in different ways, implementing rich text editing and such...

Right now I'm wondering if its possible to better the default implementation for BelongsTo what happens is you get a dropdown that calls data from the child table... So for the following schema...

  • Posts (id, title, category_id) - Categories (id, name) will get Administrate to give you a dropdown of category names on creating a new post, thats fine if you have only 5 categs, but if you have 1000 then its gonna be a long scrolling to get the one you need. So again, I'm left here wondering if its some solution/gem that can be implemented to have a autocomplete field that can search on the child table for the desired value. Or maybe this functionality its built-in and I dont even know about it... =)



I know you can use an administrate custom field to customize the form field. There are some gems out there to help make that easier but I can't remember the name of the one that does this.

This one isn't quite right since it seems like it's only for belongs to, but it's almost exactly what you want:


oh! sweeeet! thats just the thing! I owe you a pint of guinness

Join the discussion
Create an account Log in

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

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

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