diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb index 9640cef..687aab8 100644 --- a/app/controllers/api/v1/search_controller.rb +++ b/app/controllers/api/v1/search_controller.rb @@ -1,4 +1,12 @@ class Api::V1::SearchController < Api::V1::ApiController + def characters + if params[:query].present? + @characters = Character.search(params[:query]).limit(10) + else + @characters = Character.all + end + end + def weapons if params[:query].present? @weapons = Weapon.search(params[:query]).limit(10) diff --git a/config/routes.rb b/config/routes.rb index c1d0734..9a2592a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,6 +12,7 @@ Rails.application.routes.draw do post 'check/email', to: 'users#check_email' post 'check/username', to: 'users#check_username' + get 'search/characters', to: 'search#characters' get 'search/weapons', to: 'search#weapons' get 'search/summons', to: 'search#summons'