I am updating two objects from a form with the code:
@court = Court.find(params[:id])
@address = @court.address
valid = @court.valid?
if @address.valid? and valid and
flash[:notice] = 'Court was successfully updated.'
redirect_to :action => 'show', :id => @court
render :action => 'edit'
If the address fails validation I get an error message like I would
expect and the information that the user just keyed is redisplayed to
If the court and address both fail validation, the error messages
appear, but the address data reverts to the state in the database and
the user changes are lost. I assume it is the way I am loading the
address, which doesn't look correct to me, but it does work when the
court information passes validation.
Any help would be appreciated.