Problem with AJAX Picklists on Edit

Folks,

I'm using a couple of picklists, populated from database tables, to
take in Country and State in a form. The Countries and States models
are in a belongs_to / has_many relationship, but not all countries
have states available in a picklist (I have them for US and Canada,
but not for the rest of the world). When this happens, I set the
state_id to null and present a textbox for the user to type in the
state.

Anyway, it works fine on initial data entry. However when I use the
same partial to perform an edit on an existing row the information for
the state isn't being shown correctly (it always shows the first state
in the US list).

Here's (part of) my _form.rhtml -

========== START OF CUT ==================
<span id="recipient_countries">
<p><label for="order_recipient_country_id">Country</label><br/>
<%=
  @recipient_countries = Country.find(:all, :order =>
"display_priority,country_name")
  collection_select(:order,
            :recipient_country_id,
                      @recipient_countries,
            :id, :displayname,
            options = {:prompt => "- Select Country -"},
             html_options =
            {
            :onChange => "new Ajax.Updater('recipient_states',
            '/order/recipient_country_changed/' +
this[this.selectedIndex].value,
            {asynchronous:true, evalScripts:true});"
            }
)
%></p>
</span>

<span id="recipient_states">
  <%= render :partial => "recipient_states", :locals =>
{:recipient_country_id => @recipient_countries[0].id} %>
</span>
================ END OF CUT ================

And here is the method "recipient_country_changed" from the controller

OK,

I got that working ... it seems that just coding -

:locals => {:recipient_country_id => @recipient_countries.id}

in place of

:locals => {:recipient_country_id => @recipient_countries[0].id}

does the trick.

But when I used the same technique further down in my code I started running
into an issue, where this was sending through a large negative number when
the screen was first displayed (I printed the value), but then when I used
the drop boxes thereafter everything was fine. It is as if when I first
display the form that this particular value isn't getting set up correctly.

Any clues ?

Thanks

Phil