2015-10-13 16:38:33 -04:00
|
|
|
class Admin::VersionsController < Admin::BaseController
|
|
|
|
def show
|
2015-10-14 09:21:16 -04:00
|
|
|
@version = PaperTrail::Version.find(params[:id]).reify(has_one: true)
|
|
|
|
|
2015-10-13 16:38:33 -04:00
|
|
|
type = @version.class.to_s.underscore
|
|
|
|
instance_variable_set('@' + type, @version)
|
|
|
|
|
|
|
|
render "admin/#{type.pluralize}/show"
|
|
|
|
end
|
|
|
|
|
2015-10-14 09:21:16 -04:00
|
|
|
def revert
|
|
|
|
@version = PaperTrail::Version.find(params[:id])
|
|
|
|
|
|
|
|
if @version.reify(has_one: true)
|
|
|
|
@version.reify(has_one: true).save!
|
|
|
|
else
|
|
|
|
@version.item.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to :back, notice: "Undid #{@version.event}!"
|
|
|
|
end
|
|
|
|
|
2015-10-13 16:38:33 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
def set_version
|
|
|
|
end
|
|
|
|
end
|