Skip to content
Browse files

Re-implement fuzzy lookup. Why was this taken out?

  • Loading branch information...
1 parent 152e74c commit 39e8f223f0d1fd41785a28a1089e1540bf67c4ef @radar radar committed Feb 23, 2009
Showing with 2 additions and 0 deletions.
  1. +2 −0 leaves/logga/controller.rb
View
2 leaves/logga/controller.rb
@@ -128,6 +128,8 @@ def find_constant(stem, sender, reply_to, name, entry=nil, opts={})
constants = Constant.find_all_by_name(name)
# Find by name beginning with <blah>.
constants = Constant.all(:conditions => ["name LIKE ?", name + "%"]) if constants.empty?
+ # Find by fuzzy.
+ constants = Constant.find_by_sql("select * from constants where name LIKE '%#{for_sql(name.split("").join("%"))}%'") if constants.empty?
if constants.size > 1
# Narrow it down to the constants that only contain the entry we are looking for.
if !entry.nil?

0 comments on commit 39e8f22

Please sign in to comment.
Something went wrong with that request. Please try again.