How to use tomselect to create and edit a "belongs_to :many relation" with Ruby on Rails - DEV Community

14-May-2023 521
Imagine that you have a has_many xxx :through relation where you need to select several records out of thousands. Selection should be using an html select tag which would prove problematic if you had to select say 5 records out of 50.000 or moreWe are going to build on this great example https://coolrequest.dev/2021/11/25/replace_select2.html where the author uses rails 7, tomselect, stimulus to fetch the data with ajax and autocomplete.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle