1
0
Fork 0
dokkan-data-rails/app/controllers/admin/versions_controller.rb
2015-10-14 10:00:16 -04:00

27 lines
578 B
Ruby

class Admin::VersionsController < Admin::BaseController
def show
@version = PaperTrail::Version.find(params[:id]).reify(has_one: true)
type = @version.class.to_s.underscore
instance_variable_set('@' + type, @version)
render "admin/#{type.pluralize}/show"
end
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
private
def set_version
end
end