2012-11-21 12:09:01 +00:00
|
|
|
class Api::V1::SearchController < Api::V1::BaseController
|
|
|
|
def index
|
2015-04-01 22:34:14 +01:00
|
|
|
authorize :search
|
|
|
|
|
|
|
|
search = Search.new(params[:query], current_user, paginate_params)
|
2014-11-24 21:01:39 +00:00
|
|
|
types = Search::TYPES.find{ |t| t == params[:type] } || Search::TYPES
|
|
|
|
@results = {}
|
|
|
|
[types].flatten.each do |type|
|
|
|
|
@results[type] = search.send(type)
|
|
|
|
end
|
2012-11-21 12:09:01 +00:00
|
|
|
end
|
2015-04-01 22:34:14 +01:00
|
|
|
end
|