Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Model code
- class Product
- define_index do
- indexes :name, :sortable => true
- indexes :description
- indexes manufacturer_name
- indexes merchant.name, :as => :merchant_name
- indexes category.name, :as => :category_name
- indexes price, :sortable => true
- end
- end
- ## Results
- > Product.search("foo", :order => :name).map(&:name)
- # => ["100 Superstar Guitar Sounds On A Stompbox Budget", "21st Century Rock Buskers Book 2", "21st Century Rock Tab 2", "21st Century Rock Tab 3", "21st Century Rock: Play-Along Chord Songbook", "A Song's Best Friend: John Denver Remembered", "Akim-Foo the History of a Failure (Gold Coast 1873-74 Campaign)", "Best of Foo Fighters: Guitar Signature Licks", "Blade Dancer", "Buzz The Pop Quiz Solus", "Buzz! The Pop Quiz Bundle", "Buzz! The Pop Quiz Bundle - PlayStation 2", "Buzz! The Pop Quiz Solus - PlayStation 2", "CD - Art", "Cab Calloway - The Swing Era [Spanish Import]", "Cinema Of Vengeance", "Coheed And Cambria / No World For Tomorrow", "Coheed And Cambria / No World For Tomorrow", "Complete Music Foo Viola And Piano [Sacd/Cd Hybrid]", "Counting Crows / Saturday Nights And Sunday Mornings"]
- > Product.search("foo", :order => :category_name).map(&:name)
- # => []
Add Comment
Please, Sign In to add comment