class SchoolsController < ApplicationController def school_list schools = School.all search = params[:search].to_s.strip if search.present? schools = schools.where('name Like ?', "%#{search}%") end render_ok(school_names: schools.pluck(:name)) end def for_option render_ok(schools: School.select(:id, :name).as_json) end end