def update
      @post = LatoBlog::Post.find_by(id: params[:id])
      return unless check_post_presence

      # update for autosaving
      autosaving = params[:autosave] && params[:autosave] == 'true'
      if autosaving
        @post.update(edit_post_params)
        update_fields
        render status: 200, json: {} # render something positive :)
        return
      end

      # check post data update
      unless @post.update(edit_post_params)
        flash[:danger] = @post.errors.full_messages.to_sentence
        redirect_to lato_blog.edit_post_path(@post.id)
        return
      end

      # update single fields
      unless update_fields
        flash[:warning] = LANGUAGES[:lato_blog][:flashes][:post_update_fields_warning]
        redirect_to lato_blog.edit_post_path(@post.id)
        return
      end

      # render positive response
      flash[:success] = LANGUAGES[:lato_blog][:flashes][:post_update_success]
      redirect_to lato_blog.post_path(@post.id)
    end
def update
      @post = LatoBlog::Post.find_by(id: params[:id])
      return unless check_post_presence

      # update for autosaving
      autosaving = params[:autosave] && params[:autosave] == 'true'
      if autosaving
        @post.update(edit_post_params)
        update_fields
        render status: 200, json: {} # render something positive :)
        return
      end

      # check post data update
      unless @post.update(edit_post_params)
        flash[:danger] = @post.errors.full_messages.to_sentence
        redirect_to lato_blog.edit_post_path(@post.id)
        return
      end

      # update single fields
      unless update_fields
        flash[:warning] = LANGUAGES[:lato_blog][:flashes][:post_update_fields_warning]
        redirect_to lato_blog.edit_post_path(@post.id)
        return
      end

      # render positive response
      flash[:success] = LANGUAGES[:lato_blog][:flashes][:post_update_success]
      redirect_to lato_blog.post_path(@post.id)
    end
This function updates a post.