Skip to content
This repository was archived by the owner on Mar 9, 2020. It is now read-only.

Commit e5d1137

Browse files
committed
Implement a JSON API codepath in People#search_by_name
1 parent dfa35be commit e5d1137

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

app/controllers/people_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ def destroy
4444

4545
def search_by_name
4646
@people = Person.where("last_name LIKE '%' || ? || '%'", params[:name]) || []
47-
render :index
47+
respond_to do |format|
48+
format.html { render :index }
49+
format.json { render json: @people.pluck(:id) }
50+
end
4851
end
4952

5053
private

0 commit comments

Comments
 (0)