I am completing loading and cropping an avatar using ajax submit.
I send a base64 image via ajax and then convert my image to a carrier.
Everything works fine, except for ajax answer: Missing template.
This is my ajax call:
$.ajax({ type: "post", dataType: "json", url: "/profile/update_avatar", data: { image: canvas.toDataURL() } }) .done(function(data) { // You can pull the image URL using data.url, eg: $('.user-image').html('<img src="'+data.url+'" />'); });
And this is my controller:
def update_avatar respond_to do |format| if current_user.update_cropped_avatar(params[:image]) format.js format.html { render :nothing => true, :notice => 'Update SUCCESSFUL!' } else format.html { render :action => "edit" } format.json { render :json => current_user.errors, :status => :unprocessable_entity } end end
end
I do not need to display the template ... but the error is:
Missing template profiles/update_avatar, application/update_avatar with {:locale=>[:it], :formats=>[:js, :html], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml]}.
Why?
jquery ajax ruby-on-rails
Roberto pezzali
source share