hello:
An action needed to test is: def register @user=User.new(params[:user])
if params[:user] && @user.save # if province=="北京"...,set the city attr'value the same as province province=params[:user][:province] if province=="北京" || province=="天津" || province=="重庆" || province=="上海" || province=="香港" || province=="澳门" @user.city=@user.province @user.save end session[:login]=@user.id flash[:register]="#{@user.name}已创建" redirect_to :action=>"upanel" else render :action=>"register" end end