From 8d084cf690a78eae0df5c9e13b34ed3c08f6e161 Mon Sep 17 00:00:00 2001 From: hukl Date: Fri, 1 May 2009 18:14:59 +0200 Subject: introducing the restore revision functionality --- app/controllers/revisions_controller.rb | 6 ++++++ app/views/revisions/show.html.erb | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/controllers/revisions_controller.rb b/app/controllers/revisions_controller.rb index 7ae22f8..e2c0432 100644 --- a/app/controllers/revisions_controller.rb +++ b/app/controllers/revisions_controller.rb @@ -32,4 +32,10 @@ class RevisionsController < ApplicationController @node = Node.find(params[:id]) end + def restore + page = Page.find(params[:id]) + page.node.restore_revision! page.revision + flash[:notice] = "Revision #{page.revision} restored" + redirect_to :back + end end diff --git a/app/views/revisions/show.html.erb b/app/views/revisions/show.html.erb index 2a4a9a1..ebda18d 100644 --- a/app/views/revisions/show.html.erb +++ b/app/views/revisions/show.html.erb @@ -23,11 +23,21 @@ <%= page.title %> <%= page.user.try(:login) %> <%= page.updated_at %> - <%= link_to 'show', node_path(page.node) %> + + <%= link_to 'show', node_path(page.node) %> + + + <%= link_to( + 'restore', + restore_revision_path(page), + :method => :put, + :confirm => "Restore this revision?" + ) %> + <% end %> - <%= submit_tag 'Diff revisions' %> + <%= submit_tag 'Diff revisions' %> -- cgit v1.3