fix search. Was broken because of removal of user_id from taggings. Fixes #831

This commit is contained in:
Reinier Balt 2009-01-21 22:11:31 +01:00
parent 8ff7afb88c
commit 2472866baa

View file

@ -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