Skip to content

Instantly share code, notes, and snippets.

@tobstarr
Created October 17, 2009 16:52
Show Gist options
  • Save tobstarr/212400 to your computer and use it in GitHub Desktop.
Save tobstarr/212400 to your computer and use it in GitHub Desktop.
class Product < ActiveRecord::Base
define_index do
indexes :name
end
end
class Album < Product
end
class SonyAlbum < Album
end
Product.create!(:name => "Product")
Album.create!(:name => "Album")
SonyAlbum.create!(:name => "Sony Album")
# rake thinking_sphinx:rebuild
Product.search.map(&:name) => ["Product", "Album", "Sony Album"]
Album.search.map(&:name) => ["Album", "Sony Album"]
SonyAlbum.search.map(&:name) => ["Sony Album"]
# move define_index into Album
class Product < ActiveRecord::Base
end
class Album < Product
define_index do
indexes :name
end
end
class SonyAlbum < Album
end
# rake thinking_sphinx:rebuild
Product.search.search.map(&:name) => "undefined method `search'" (obvious)
Album.search.search.map(&:name) => ["Album"]
SonyAlbum.search.map(&:name) => []
# Problem: explicit "AND `products`.`type` = 'Album'" in WHERE clause of source album_core_0 in development.sphinx.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment