After I run
rails generate scaffold User
The generated controller function in Rails 3.2.11 for updating a user looks like this:
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to @user, notice: 'User was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
The line I'm curious about is returning head :no_content
for a successful JSON update request. I've done some googling, as I was guessing that this is some sort of RESTful property, to not return the updated object, but I couldn't find anything that claimed that was the case.
Why is this the default, versus returning the JSON representation of the User object post-update?