I can’t figure out how to get the collection_select to correctly
identify and select the appropriate option in the drop down to begin
with. i have checked that charge.offense_level contains the correct
value to begin with (a number between 1 and 10) but the view still
defaults to the first option and not the one contained in the
charge.offense_level. what am i doing wrong? any suggestions? I have
also tried: <%= collection_select “charge”, “offense_level”,
@charge_types, :id, :full_name %> but that doesn’t work either.
@charges contains multiple records obtained from a find_by_sql query.
each record has 3 fields: charge_name, charge_id_number, offense_level
@charge_type.id should be equal to the @charge.offense_level
the view - update_charges.rhtml:
Add missing records to charges table
<%= start_form_tag %>
Charge id number | Charge name | Classification level | <%= render :partial => 'charge', :collection => @charges %>
---|
the partial - _charge.rhtml:
here is the generated html from the source: