I have two models: UserDevice
and UserInfo
as follows (in schema.rb):
create_table \"user_devices\", force: :cascade do |t|
t.int
Yes. Check out chosen_rails gem.
Make sure to follow installation recommendations carefully (i.e. requiring js's, css's and so on).
Your user_info
input will look something like this:
f.input :user_info,
collection: -> { UserInfo.pluck(:id, :email) },
input_html: { class: 'chosen-select' }
Here is an example as per docs:
f.association :user_info,
collection: UserInfo.pluck(:id, :email),
include_blank: true,
input_html: { class: 'chosen-select' }
But I do not remember if Formtastic has f.association
.
You should try different compositions of these two examples.
What it would do, is you will start type email
(you can pick any other attribute) and it will immediately pick only these, which are matching to already typed letters.