我有他在控制器的更新操作中的代碼。代碼工作時創建,但似乎並沒有踢下更新:如何從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