I am trying to create a dynamic select box (contact_preferences options list) based on a selection made in another select box (user contact_preference_opt_in). I am using form_for to build the form that has user contact_preference_opt_in select box. The contact_preferences options list select box is in a partial. I use observe_field on first select box which calls an action (passes the selected value to it) to build an array used to populate the second drop down. All this works well but when I submit the form the second select box selection is not sent in the form (params).
Currently I am using the select helper (e.g. select(:user, :contact_preference, @preferences) where @preferences array is populated in the action. Can I use this inside form_for rather than f.select?
Seems like I can't use f.select way of populating the select box in the partial as it does not know about the context of variable f when the partial is called from the action.
This should be common problem and I must be doing something wrong here.