Skip to content
Snippets Groups Projects
Commit 1d196681 authored by Marcela Ribeiro de Oliveira's avatar Marcela Ribeiro de Oliveira
Browse files

Merge branch 'master' of gitlab.c3sl.ufpr.br:portalmec/portalmec into stable

parents e2ca7b86 48873f38
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,7 @@ module Paginator
def limit
return params[:limit].to_i if !params[:limit].blank?
return (offset + params[:results_per_page].to_i - 1) if !params[:results_per_page].blank?
return params[:results_per_page].to_i if !params[:results_per_page].blank?
return 12
end
......
......@@ -44,8 +44,13 @@ class V1::SearchController < ApplicationController
# GET v1/search/tag
# GET v1/search/tag.json
def tag
results = TagSearchService.search(Tag.find(tag_search_params[:id]))
render json: paginate(results)
t = Tag.find_by_name(tag_search_params[:name])
if t.nil?
render json: {"error": "Tag not found."}, status: :unprocessable_entity
else
results = TagSearchService.search(t)
render json: paginate(results), status: :ok
end
end
private
......@@ -60,6 +65,6 @@ class V1::SearchController < ApplicationController
end
def tag_search_params
params.permit(:page, :results_per_page, :id)
params.permit(:page, :results_per_page, :name)
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment