Skip to content

Instantly share code, notes, and snippets.

@thredup
thredup / gist:899719
Created April 2, 2011 18:12
Thinking Sphinx Definition
define_index do
indexes firstname, :sortable => true
indexes lastname, :sortable => true
has girls_sizes(:id), :as => :girls_size_ids
has boys_sizes(:id), :as => :boys_size_ids
has created_at
where "users.state = 'active'"
@thredup
thredup / gist:899716
Created April 2, 2011 18:09
Sphinx Post Schema
# User
has_many :packages
# Package
gender:string
belongs_to :size, :class_name => "Size"
@thredup
thredup / gist:899717
Created April 2, 2011 18:11
Additional Schema for Sphinx Post
has_many :recent_kids_packages, :conditions => ["packages.created_at > ?",6.months.ago], :class_name => "Package", :foreign_key => "parent_id"
has_many :girls_sizes, :source => :size, :through => :recent_kids_packages, :conditions => {"packages.gender" => 'girls'}, :foreign_key => "size_id"
has_many :boys_sizes, :source => :size, :through => :recent_kids_packages, :conditions => {"packages.gender" => 'boys'}, :foreign_key => "size_id"
$(document).click(function(ev){
if($(ev.target).hasClass("some-color-class")){
// do something
}
});