lib/search_rails.rb in search_rails-1.1.2 vs lib/search_rails.rb in search_rails-1.1.3
- old
+ new
@@ -324,10 +324,11 @@
if attribute[1] == 'integer' || attribute[1] == 'decimal'
line.puts " " + object.capitalize.singularize + ".where('cast(" + attribute[0] + " AS VARCHAR) LIKE ?', '%' + @search.search + '%').each { |" + attribute[0] + "| @" + object.downcase.pluralize + ".any? { |f| f.id == " + attribute[0] + ".id } ? true : @" + object.downcase.pluralize + " << " + attribute[0] + " }"
elsif attribute[1] == 'boolean'
line.puts " if @search.search.downcase == 'true' || @search.search.downcase == 'tru' || @search.search.downcase == 'tr' || @search.search.downcase == 't'"
line.puts " " + object.capitalize.singularize + ".where(" + attribute[0] + ": true).each { |" + attribute[0] + "| @" + object.downcase.pluralize + ".any? { |f| f.id == " + attribute[0] + ".id } ? true : @" + object.downcase.pluralize + " << " + attribute[0] + " }"
- line.puts " else @search.search.downcase == 'false' || @search.search.downcase == 'fals' || @search.search.downcase == 'fal' || @search.search.downcase == 'fa' || @search.search.downcase == 'f'"
+ line.puts " end"
+ line.puts " if @search.search.downcase == 'false' || @search.search.downcase == 'fals' || @search.search.downcase == 'fal' || @search.search.downcase == 'fa' || @search.search.downcase == 'f'"
line.puts " " + object.capitalize.singularize + ".where(" + attribute[0] + ": false).each { |" + attribute[0] + "| @" + object.downcase.pluralize + ".any? { |f| f.id == " + attribute[0] + ".id } ? true : @" + object.downcase.pluralize + " << " + attribute[0] + " }"
line.puts " end"
else
line.puts " " + object.capitalize.singularize + ".where('lower(" + attribute[0] + ") LIKE ?', '%' + @search.search + '%').each { |" + attribute[0] + "| @" + object.downcase.pluralize + ".any? { |f| f.id == " + attribute[0] + ".id } ? true : @" + object.downcase.pluralize + " << " + attribute[0] + " }"
end