diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index 40a6b2fc5..907bb6130 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -1,6 +1,7 @@
class WikiPage < ActiveRecord::Base
before_save :normalize_title
- before_create :initialize_creator
+ before_validation :initialize_creator, :on => :create
+ before_validation :initialize_updater
after_save :create_version
belongs_to :creator, :class_name => "User"
validates_uniqueness_of :title, :case_sensitive => false
@@ -125,10 +126,18 @@ class WikiPage < ActiveRecord::Base
)
end
end
+
+ def updater_name
+ User.id_to_name(updater_id)
+ end
def initialize_creator
self.creator_id = CurrentUser.user.id
end
+
+ def initialize_updater
+ self.updater_id = CurrentUser.user.id
+ end
def post_set
@post_set ||= PostSets::WikiPage.new(title, 1, 4)
diff --git a/app/views/wiki_pages/index.html.erb b/app/views/wiki_pages/index.html.erb
index b7800f885..ed7be0881 100644
--- a/app/views/wiki_pages/index.html.erb
+++ b/app/views/wiki_pages/index.html.erb
@@ -16,7 +16,7 @@
<% @wiki_pages.each do |wiki_page| %>
| <%= link_to wiki_page.pretty_title, wiki_page_path(wiki_page, :noredirect => 1) %> |
- <%= wiki_page.updated_at.strftime("%Y-%m-%d %I:%M") %> by <%= h link_to wiki_page.creator.name, user_path(wiki_page.creator) %> |
+ <%= wiki_page.updated_at.strftime("%Y-%m-%d %I:%M") %> by <%= h link_to wiki_page.updater_name, user_path(wiki_page.updater_id) %> |
<% end %>
diff --git a/db/migrate/20130320070700_add_updater_id_to_wiki_pages.rb b/db/migrate/20130320070700_add_updater_id_to_wiki_pages.rb
new file mode 100644
index 000000000..9443a5094
--- /dev/null
+++ b/db/migrate/20130320070700_add_updater_id_to_wiki_pages.rb
@@ -0,0 +1,5 @@
+class AddUpdaterIdToWikiPages < ActiveRecord::Migration
+ def change
+ add_column :wiki_pages, :updater_id, :integer
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index ae1917482..72ca901d6 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -2672,7 +2672,8 @@ CREATE TABLE wiki_pages (
body_index tsvector NOT NULL,
is_locked boolean DEFAULT false NOT NULL,
created_at timestamp without time zone NOT NULL,
- updated_at timestamp without time zone NOT NULL
+ updated_at timestamp without time zone NOT NULL,
+ updater_id integer
);
@@ -6258,4 +6259,6 @@ INSERT INTO schema_migrations (version) VALUES ('20130318030619');
INSERT INTO schema_migrations (version) VALUES ('20130318031705');
-INSERT INTO schema_migrations (version) VALUES ('20130318231740');
\ No newline at end of file
+INSERT INTO schema_migrations (version) VALUES ('20130318231740');
+
+INSERT INTO schema_migrations (version) VALUES ('20130320070700');
\ No newline at end of file
diff --git a/script/fixes/009.rb b/script/fixes/009.rb
new file mode 100644
index 000000000..db246856a
--- /dev/null
+++ b/script/fixes/009.rb
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment'))
+
+ActiveRecord::Base.connection.execute("set statement_timeout = 0")
+
+ActiveRecord::Base.connection.execute("update wiki_pages set updater_id = creator_id")