Issue#668 Blank STI type blows up search with Postgres

Use combination of COALESCE and NULLIF to ensure that table rows with
blank string for type are cast to parent class

Note: I needed to use pg 0.15.1 to run specs and also got the following error while running specs:

ThinkingSphinx::SphinxError:
       Using the old-fashion @variables (@count, @weight, etc.) is deprecated