0
を動作しませんでしたレールに請求書コントローラでの更新のためのコードです:approved_by_corp_headの_changed? 3.1.0アプリはここ
def update
@invoice = Invoice.find(params[:id])
if @invoice.approved_by_corp_head_changed?
@invoice.approve_date_corp_head = Time.now
@invoice.corp_head_id = session[:user_id]
end
if @invoice.update_attributes(params[:invoice], :as => :roles_update)
redirect_to URI.escape("/view_handler?index=0&msg=Updated")
else
flash.now[:error] = 'Not saved!'
render 'edit'
end
end
値が正しく保存されました。問題は、if @invoice.approved_by_corp_head_changed?
が常にfalseであり、IFループが決して実行されないということです。レールコンソールでは、@ invoice.approved_by_corp_head_changed?値が変更された場合はtrueです。ここで何が間違っているのでしょうか?本当にありがとう。
感謝。 @invoiceがupdate_attributesを呼び出す前に変更されたのかどうか疑問に思っていました。 view_handlerは、視聴履歴を保存するためのカスタムメソッドです。編集中または作成後に、Back Inレールがループを形成します。 – user938363