From 57a89bc76c4ac383a33223e3e217a9ce6b0976e6 Mon Sep 17 00:00:00 2001 From: Parziphal Date: Mon, 14 Jul 2014 05:42:20 -0500 Subject: [PATCH] Activated autocompleteName action. --- app/controllers/TagController.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/controllers/TagController.php b/app/controllers/TagController.php index 4653972..ad01651 100755 --- a/app/controllers/TagController.php +++ b/app/controllers/TagController.php @@ -22,15 +22,16 @@ class TagController extends ApplicationController }); } - // # Generates list of tag names matching parameter term. - // # Used by jquery.ui.autocomplete. - // public function autocompleteName() - // { - // $this->tags = Tag.where(['name ILIKE ?', "*#{$this->params()->term}*".to_escaped_for_sql_like]).pluck(:name) - // $this->respondTo(array( - // format.json { $this->render(array('json' => $this->tags }) - // )); - // } + # Generates list of tag names matching parameter term. + # Used by jquery.ui.autocomplete. + public function autocompleteName() + { + $this->tags = Tag::where('name LIKE ?', '%' . $this->params()->term . '%')->pluck('name'); + # MI: RoR can respond to requests by reading the "Accept" request header. So even though + # the request URL doesn't have the .json extension, it will respond JSON if the request accepts + # it. But this is not the case here, so this action will always respond JSON. + $this->render(['json' => $this->tags]); + } public function summary() {