def destroy
      @history.transaction do
        @history.destroy!
        @history.page.reload

        latest_version = @history.page.histories.order(created_at: :desc).first
        if latest_version.present?
          @history.page.update_attributes!(latest_version_id: latest_version.id)
        else
          # We can't have a page with no history
          @history.page.destroy!
        end

        redirect_to @history.page, notice: 'History was successfully destroyed.'
      end
    end
def destroy
      @history.transaction do
        @history.destroy!
        @history.page.reload

        latest_version = @history.page.histories.order(created_at: :desc).first
        if latest_version.present?
          @history.page.update_attributes!(latest_version_id: latest_version.id)
        else
          # We can't have a page with no history
          @history.page.destroy!
        end

        redirect_to @history.page, notice: 'History was successfully destroyed.'
      end
    end
DELETE /histories/1