This commit is contained in:
@@ -2,8 +2,12 @@ class WikiPagesController < ApplicationController
|
|||||||
rescue_from Wiki::Commit::Conflict, with: :render_wiki_conflict
|
rescue_from Wiki::Commit::Conflict, with: :render_wiki_conflict
|
||||||
|
|
||||||
def index
|
def index
|
||||||
pages = WikiPage.all
|
title = params[:title].to_s.strip
|
||||||
render json: pages.as_json(methods: [:title])
|
return render json: WikiPage.all.as_json(methods: [:title]) if title.blank?
|
||||||
|
|
||||||
|
q = WikiPage.joins(:tag_name).includes(:tag_name)
|
||||||
|
.where('tag_names.name LIKE ?', "%#{ WikiPage.sanitize_sql_like(title) }%")
|
||||||
|
render json: q.limit(20).as_json(methods: [:title])
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@@ -122,14 +126,7 @@ class WikiPagesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def search
|
def search
|
||||||
title = params[:title].to_s.strip
|
index
|
||||||
|
|
||||||
q = WikiPage.joins(:tag_name).includes(:tag_name)
|
|
||||||
if title.present?
|
|
||||||
q = q.where('tag_names.name LIKE ?', "%#{ WikiPage.sanitize_sql_like(title) }%")
|
|
||||||
end
|
|
||||||
|
|
||||||
render json: q.limit(20).as_json(methods: [:title])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def changes
|
def changes
|
||||||
|
|||||||
Reference in New Issue
Block a user