If you use thinking-sphinx, this is a nice trick if you need to index polymorphic attributes.
In our case, we have questions that could belong to campaigns or startups. So those questions are polymorphic. But we still need to index them. Here is the description of the index in pure SQL:
indexes "CASE questions.subject_type
WHEN 'Campaign' THEN (
WHERE campaigns.id = questions.subject_id
WHEN 'Startup' THEN (
WHERE startups.id = questions.subject_id
END", :as => :startup