【发布时间】:2011-01-05 01:33:06
【问题描述】:
我让他在我的控制器更新操作中跟踪代码。代码在创建时有效,但在更新时似乎没有启动:
def update
@contact = Contact.find(params[:id])
# bug, why isn't this working?
unless @contact.fax.empty?
@contact.fax = "1" + Phony.normalize(@contact.fax)
end
unless @contact.phone.empty?
@contact.phone = "1" + Phony.normalize(@contact.phone)
end
if @contact.update_attributes(params[:contact])
flash[:notice] = "Successfully updated contact."
redirect_to @contact
else
render :action => 'edit'
end
结束
【问题讨论】:
标签: ruby-on-rails activerecord model