Class: CargoWiki::VersionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/cargo_wiki/versions_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



3
4
5
6
7
8
9
10
# File 'app/controllers/cargo_wiki/versions_controller.rb', line 3

def index
  if params[:article_id]
    @article = Article.find(params[:article_id])
    @versions = @article.versions.all.reverse
  else
    @versions = Version.order('created_at DESC')
  end
end

#showObject



12
13
14
15
16
17
18
19
# File 'app/controllers/cargo_wiki/versions_controller.rb', line 12

def show
  @article = Article.find(params[:article_id])
  @version = @article.versions.find(params[:id])

  @version_article = @version.next.try(:reify)
  @version_article = @article if @version_article.nil?
  @version_article.title = "[#{@version.index}] #{@version_article.title}"
end