My controller is
def destroy
@image.destroy
respond_to do |format|
  format.html
  format.json { render json: 'success' }
end
end
I want that request from html then it redirect to :back like
flash[:notice] = "Image Successfully deleted"
redirect_to :back
it works fine when I can't deal with json. I want to combine both of them so they send response accordingly to html or ajax request
You can just put it inside the respond_to block for the html format
def destroy
  @image.destroy
  respond_to do |format|
    format.html do
      flash[:notice] = "Image Successfully deleted"
      redirect_to :back
    end
    format.json do
      render json: 'success'
    end
  end
end
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With