diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index a5af8b32..d91c0f7b 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -19,7 +19,8 @@ class PagesController < ApplicationController end def new - @page = Page.new(:title => params[:title].capitalize.gsub("-", " ")) + @page = Page.new + @page.title = params[:title].capitalize.gsub("-", " ") if params[:title] respond_to do |format| format.html # new.html.erb @@ -83,13 +84,13 @@ class PagesController < ApplicationController def version @page = Page.find(params[:id]) - @version = @page.versions[params[:version].to_i - 1] + @version = Page::Version.find_by_page_id_and_lock_version params[:id], params[:version] end def revert @page = Page.find(params[:id]) - @page.revert_to(params[:version].to_i) + @page.revert_to!(params[:version].to_i) - render :action => 'edit' + redirect_to wiki_page_path(@page.permalink) end end diff --git a/app/models/page.rb b/app/models/page.rb index 65f5abc2..96ca4c00 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -2,7 +2,7 @@ class Page < ActiveRecord::Base belongs_to :user, :foreign_key => 'updated_by' - acts_as_versioned + acts_as_versioned :version_column => :lock_version self.non_versioned_columns += ['permalink', 'created_at'] validates_presence_of :title, :body diff --git a/app/views/pages/show.html.haml b/app/views/pages/show.html.haml index e536a3b9..c516d635 100644 --- a/app/views/pages/show.html.haml +++ b/app/views/pages/show.html.haml @@ -7,10 +7,9 @@ %ul - for version in @page.versions.reverse %li - = link_to format_time(version.updated_at), version_page_path(@page, :version => version.version) + = link_to format_datetime(version.updated_at), version_page_path(@page, :version => version.lock_version) = "(#{User.find(version.updated_by).nick})" - = render :partial => 'body' %hr.clear/ @@ -19,4 +18,4 @@ | = link_to "Seite löschen", @page, :method => :delete, :confirm => "Achtung, möchtest Du wirklich die Wikiseite löschen?" | - = "Zuletzt bearbeitet: #{format_datetime @page.updated_at} (#{@page.user.nick})" + = "Zuletzt bearbeitet am #{format_datetime @page.updated_at} (#{@page.user.nick})" diff --git a/app/views/pages/version.html.haml b/app/views/pages/version.html.haml index 7bdc15a8..3e6ab40a 100644 --- a/app/views/pages/version.html.haml +++ b/app/views/pages/version.html.haml @@ -5,7 +5,7 @@ %ul %li= "Autor: #{User.find(@version.updated_by).nick}" %li= link_to "Aktuelle Version sehen", wiki_page_path(:permalink => @page.permalink) - %li= link_to "Auf diese Version zurücksetzen", revert_page_path(@page, :version => @version.version) + %li= link_to "Auf diese Version zurücksetzen", revert_page_path(@page, :version => @version.lock_version) = wikified_body @version.body diff --git a/db/migrate/20090325175756_create_pages.rb b/db/migrate/20090325175756_create_pages.rb index 96e76659..316a418d 100644 --- a/db/migrate/20090325175756_create_pages.rb +++ b/db/migrate/20090325175756_create_pages.rb @@ -6,7 +6,6 @@ class CreatePages < ActiveRecord::Migration t.string :permalink t.integer :lock_version, :default => 0 t.integer :updated_by - t.integer :version t.timestamps end