From f47e122407450bda7973b6b9998fe573506f956b Mon Sep 17 00:00:00 2001 From: RainChen Date: Wed, 16 Oct 2013 15:34:12 +0800 Subject: [PATCH 1/3] enable to run `rake test` for testing --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index 5c6c4af..f2b4e8d 100644 --- a/Gemfile +++ b/Gemfile @@ -9,4 +9,6 @@ gem "actionpack", "~> 3.1" group :development do gem "shoulda", "~> 2.11" + gem 'rake' + gem 'sqlite3' end \ No newline at end of file From b993e11c1ca1aea1875db211c1b1bc9e25e0f7ec Mon Sep 17 00:00:00 2001 From: RainChen Date: Wed, 16 Oct 2013 15:45:06 +0800 Subject: [PATCH 2/3] change source of Gemfile to "https://rubygems.org" --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index f2b4e8d..f9f92ea 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source :rubygems +source 'https://rubygems.org' # Don't do a "gemspec" here. Seriously. It jacks up Jeweler. From 110833552bea01cfb23e697ac68cccc952d1b5e1 Mon Sep 17 00:00:00 2001 From: RainChen Date: Wed, 16 Oct 2013 16:19:18 +0800 Subject: [PATCH 3/3] make sure method_name like "phone" will not convert to "phodoes_not_equal" --- lib/meta_search/builder.rb | 1 + lib/meta_search/utility.rb | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/meta_search/builder.rb b/lib/meta_search/builder.rb index 024a080..14a7ee3 100644 --- a/lib/meta_search/builder.rb +++ b/lib/meta_search/builder.rb @@ -147,6 +147,7 @@ def matches_attribute_method(method_id) where = Where.new(method_id) rescue nil return nil unless method_name && where match = method_name.match("^(.*)_(#{where.name})=?$") + return nil unless match attribute, predicate = match.captures attributes = attribute.split(/_or_/) if attributes.all? {|a| where.types.include?(column_type(a))} diff --git a/lib/meta_search/utility.rb b/lib/meta_search/utility.rb index 983f39e..6b1cb43 100644 --- a/lib/meta_search/utility.rb +++ b/lib/meta_search/utility.rb @@ -9,11 +9,12 @@ module Utility #:nodoc: private def preferred_method_name(method_id) - method_name = method_id.to_s + method_name = method_id.to_s.dup # use dup otherwise sub! will change the value of method_id where = Where.new(method_name) rescue nil return nil unless where where.aliases.each do |a| - break if method_name.sub!(/#{a}(=?)$/, "#{where.name}\\1") + # make sure method_name like "phone" will not convert to "phodoes_not_equal" + break if method_name.sub!(/_#{a}(=?)$/, "_#{where.name}\\1") end method_name end