Skip to content

Instantly share code, notes, and snippets.

@joshk
Created April 21, 2010 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshk/373513 to your computer and use it in GitHub Desktop.
Save joshk/373513 to your computer and use it in GitHub Desktop.
define_index do
...
# it should be this
indexes genres(:name)
# indexes special_tags(:name), :as => 'special_tags'
# and the ugly way to get special_tags working
indexes "GROUP_CONCAT(DISTINCT `special_tags_performances`.`name` SEPARATOR ' ')", :as => 'special_tags'
set_property :custom_joins => "LEFT OUTER JOIN `taggings` special_tags_performances_join ON (`performances`.`id` = `special_tags_performances_join`.`taggable_id` AND `special_tags_performances_join`.`taggable_type` = 'Performance') LEFT OUTER JOIN `tags` special_tags_performances ON (`special_tags_performances`.`id` = `special_tags_performances_join`.`tag_id`) AND `special_tags_performances`.`context` = 'special_tags'"
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment