0

Rails 4 アプリで best_in_place gem を使用しようとしています。フィールドへの有効な編集を更新することはできますが、無効な値を入力してもエラー メッセージは表示されません。.purr スタイリング ルールを追加しましたが、まだ満足していません。

コントローラーで次を使用します。

def update
  @transact = Transact.find(params[:id])

  respond_to do |format|
    if @transact.update_attributes(transact_params)
      flash[:notice] = 'Transaction was successfully updated.'
      format.html { redirect_to(@transact) }
      format.xml  { head :ok }
      format.json { respond_with_bip(@transact) }
    else
      @errors = @transact.errors
      format.html { render :action => "edit" }
      format.xml  { render :xml => @transact.errors, :status => :unprocessable_entity }
      # format.json {
      #   render :json => @errors.full_messages,
      #   :status => :unprocessable_entity
      # }
      format.json { respond_with_bip(@transact) }
    end
  end
end

また、上記のコメントアウトされたコードも試しましたが、同様の結果が得られました。

無効な値に対するサーバーの応答は次のとおりです。

Processing by TransactsController#update as JSON
  Parameters: {"transact"=>{"shares"=>"6741433.0x"}, "authenticity_token"=>"e+1ZEhVYuEMDURf81Kcxg0Ld28BfY60rRFRSZUq8RsY=", "id"=>"144314"}
  Transact Load (0.5ms)  SELECT "transacts".* FROM "transacts" WHERE "transacts"."id" = $1 LIMIT 1  [["id", "144314"]]
   (0.1ms)  BEGIN
   (0.3ms)  ROLLBACK
Completed 422 Unprocessable Entity in 60ms (Views: 0.2ms | ActiveRecord: 0.9ms)

私が間違っていることは明らかですか?

4

2 に答える 2

0

記録として、上記の私のコメントを参照してください。

これを見落としている他の誰かに役立つことを願っています。

これが答えだと思いました。

于 2013-11-15T11:42:58.267 に答える