1
0
Fork 0
dokkan-data-rails/app/controllers/admin/versions_controller.rb

28 lines
578 B
Ruby
Raw Normal View History

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)
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
private
def set_version
end
end