mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 14:42:32 -05:00
29 lines
648 B
Ruby
29 lines
648 B
Ruby
# frozen_string_literal: true
|
|
|
|
class TemplatesVersionsController < ApplicationController
|
|
load_and_authorize_resource :template
|
|
|
|
def index
|
|
@versions = @template.template_versions.order(id: :desc).preload(:author)
|
|
|
|
respond_to do |format|
|
|
format.json { render json: @versions.as_json(TemplateVersions::SERIALIZE_PARAMS) }
|
|
format.html
|
|
end
|
|
end
|
|
|
|
def show
|
|
version = @template.template_versions.find(params[:id])
|
|
|
|
render json: TemplateVersions.serialize(version)
|
|
end
|
|
|
|
def create
|
|
authorize!(:update, @template)
|
|
|
|
TemplateVersions.find_or_create_for(@template, author: current_user)
|
|
|
|
head :ok
|
|
end
|
|
end
|