Commit 167f26b9 authored by Riyad Preukschas's avatar Riyad Preukschas

Add an ordering scope to Wiki

parent 5aada8cc
......@@ -4,14 +4,14 @@ class WikisController < ProjectResourceController
before_filter :authorize_admin_wiki!, only: :destroy
def pages
@wikis = @project.wikis.group(:slug).order("created_at")
@wiki_pages = @project.wikis.group(:slug).ordered
end
def show
if params[:old_page_id]
@wiki = @project.wikis.find(params[:old_page_id])
if params[:version_id]
@wiki = @project.wikis.find(params[:version_id])
else
@wiki = @project.wikis.where(slug: params[:id]).order("created_at").last
@wiki = @project.wikis.where(slug: params[:id]).ordered.first
end
@note = @project.notes.new(noteable: @wiki)
......@@ -29,7 +29,7 @@ class WikisController < ProjectResourceController
end
def edit
@wiki = @project.wikis.where(slug: params[:id]).order("created_at").last
@wiki = @project.wikis.where(slug: params[:id]).ordered.first
@wiki = Wiki.regenerate_from @wiki
end
......@@ -47,7 +47,7 @@ class WikisController < ProjectResourceController
end
def history
@wikis = @project.wikis.where(slug: params[:id]).order("created_at")
@wiki_pages = @project.wikis.where(slug: params[:id]).ordered
end
def destroy
......
......@@ -25,6 +25,8 @@ class Wiki < ActiveRecord::Base
before_update :set_slug
scope :ordered, order("created_at DESC")
def to_param
slug
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment