我有他在控制器的更新操作中的代码。代码工作时创建,但似乎并没有踢下更新:如何从Rails中的编辑/更新中更改inpus?
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
末
@Angela - 为您做了这项工作吗? – sethvargo 2011-01-10 02:22:09
我正在尝试它...我尝试了nother方法...我希望这个作品,我喜欢它... – Angela 2011-01-11 01:30:44
@ seth.vargo不要太离题远... ... heheh,你会知道如何使用shoulda来为此写一个测试?我不确定.... – Angela 2011-01-11 01:32:18