I ran into the same issue and resolved it by doing the following (pointed in the right direction by https://github.com/jim/carmen-rails/issues/12). It's not yet optimal, but it does the job.
<div id="shipping_tally_state_code_wrapper">
<div class="control-group carmen_state required">
<label class="carmen_state_code required control-label" for="shipping_tally_state_code"><abbr title="required">*</abbr> Province</label>
<div class="controls">
<% parent_region ||= params[:parent_region] %>
<% sub_region ||= params[:sub_region] %>
<% country = Carmen::Country.coded(parent_region) %>
<% if country.nil? %>
<span class="help-inline display-id"><em>Please select a country above</em></span>
<% elsif country.subregions? %>
<%= subregion_select_tag('shipping_tally[state_code]', sub_region, country) %>
<% else %>
<%= text_field_tag('shipping_tally[state_code]', sub_region) %>
<% end %>
</div>
</div>
</div>
And then call this partial with the following:
<%= render partial: 'shared/forms/subregion_select', :locals => { :parent_region => f.object.country_code, :sub_region => f.object.state_code } %>
Applicable js.coffee no change.
Areas to be improved:
- Using twitter bootstrap so hard coding everything instead of putting together a wrapper.
- Currently doesn't show validation errors for state_code (a required property).
- Doesn't retain the state code when switching the country. This would be easy enough to implement by passing the sub_region to the service along with the parent_region.