diff --git a/Gemfile b/Gemfile index 5c6c4af..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. @@ -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 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