diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 93bdb23e..b7711ec4 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -11,7 +11,14 @@ class SearchController < ApplicationController @found_notes = current_user.notes.find(:all, :conditions => ["body LIKE ?", terms]) @found_contexts = current_user.contexts.find(:all, :conditions => ["name LIKE ?", terms]) # TODO: limit search to tags on todos - @found_tags = current_user.tags.find(:all, :conditions => ["name LIKE ?", terms]) + @found_tags = Tagging.find_by_sql([ + "SELECT DISTINCT tags.name as name "+ + "FROM tags, taggings, todos "+ + "WHERE todos.user_id=? "+ + "AND tags.name LIKE ? " + + "AND tags.id = taggings.tag_id " + + "AND taggings.taggable_id = todos.id ", current_user.id, terms]) + #current_user.tags.find(:all, :conditions => ["name LIKE ?", terms]) @count = @found_todos.size + @found_projects.size + @found_notes.size + @found_contexts.size + @found_tags.size