Reputation: 375
I am trying to use the best_in_place gem with a Rails 4 app. I can get it to update valid edits to a field fine, but if I enter an invalid value, I don't see error messages. I have added the .purr styling rules, but still no joy.
I use the following in the controller:
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
And I've also tried the commented-out code in the above, with similar results.
Here is what the server responds on an invalid value:
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)
Is there any thing obvious I am doing wrong?
Upvotes: 0
Views: 999
Reputation: 61
I had the same problem. My solution was to include ALL these three lines in application.js:
//= require best_in_place
//= require best_in_place.purr
//= require jquery.purr
If jquery.purr or best_in_place.purr was left out, no error message was displayed to the user.
Upvotes: 2
Reputation: 375
For the record, see my comment above: I was not including best_in_place.purr.js in my javascript assets in addition to best_in_place.js.
Hope it helps someone else overlooking this.
I considered this answered.
Upvotes: 0