Skip to content

Instantly share code, notes, and snippets.

@sirramongabriel
Created January 28, 2018 21:53
Show Gist options
  • Save sirramongabriel/8df729e14c72ebd11f294f8fd8a27ef3 to your computer and use it in GitHub Desktop.
Save sirramongabriel/8df729e14c72ebd11f294f8fd8a27ef3 to your computer and use it in GitHub Desktop.
Display attempts to retain value of select when commit or patched
<!--I've tried the following -->
<%= f.collection_select(
:doctor_full_name,
@resident.doctors,
:full_name,
:full_name,
{ selected: f.object.doctor_full_name, prompt: true }
) %>
<%= f.select(
:doctor_full_name,
resident.doctors.map(&:full_name),
selected: f.object.doctor_full_name,
prompt: true
) %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment