我有这个 if 条件来检查这个国家是否不在美国
if params[:address][:country] != 'United States'
logger.info "I am in here"
@address.errors.add(:base, "We're sorry, you cant update your address")
@address.errors.add(:country, "We're sorry, you cant update your address")
end
if @address.update_attributes(params[:address])
flash[:notice] = 'Information was successfully updated.'
但是我假设如果你在对象的基础上添加了一个错误,它会停止,但没有任何东西停止更新,并且总是出现 flash 通知......我如何停止这个并添加一个 flash 错误