Problem with foreign key

Hello

I’ve a “User” model. A user, belongs to a state model.

I’ve the following in the user form:

    <%= f.select(:state_id, State.find(:all).map {|c| [c.name,
c.id]},{:prompt => "Select a canton"}, {:onchange =>
"#{remote_function(:url  => {:action => "update_municipals"},
                                                       :with =>
"'name='+value")}"}) %>

However when I add a user, it’s “state_id” is null, but if rename
state_id to “state”, the id number of the state is saved correctly.

Thanks