diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-10-21 04:43:15 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-10-21 04:43:15 +0000 |
commit | 9796d18609334eaad05188617217f2405a47a645 (patch) | |
tree | 738c1a31646f87f541e2403455611895b917a2d5 /app/models/wiki_content.rb | |
parent | f09be683232748ba649de6b3c1b62f901d9247b8 (diff) | |
download | redmine-9796d18609334eaad05188617217f2405a47a645.tar.gz redmine-9796d18609334eaad05188617217f2405a47a645.zip |
Handle deleted wiki page versions (#10852).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10684 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/wiki_content.rb')
-rw-r--r-- | app/models/wiki_content.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/app/models/wiki_content.rb b/app/models/wiki_content.rb index ac7459826..ec1cd8234 100644 --- a/app/models/wiki_content.rb +++ b/app/models/wiki_content.rb @@ -115,10 +115,18 @@ class WikiContent < ActiveRecord::Base # Returns the previous version or nil def previous - @previous ||= WikiContent::Version.find(:first, - :order => 'version DESC', - :include => :author, - :conditions => ["wiki_content_id = ? AND version < ?", wiki_content_id, version]) + @previous ||= WikiContent::Version. + reorder('version DESC'). + includes(:author). + where("wiki_content_id = ? AND version < ?", wiki_content_id, version).first + end + + # Returns the next version or nil + def next + @next ||= WikiContent::Version. + reorder('version ASC'). + includes(:author). + where("wiki_content_id = ? AND version > ?", wiki_content_id, version).first end end end |