From dc4799dda2e6c5d67ddc1138025560b096a54a8e Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Wed, 17 Aug 2016 01:01:06 +0530 Subject: [PATCH] handle posts:rebake_match task without type argument --- lib/tasks/posts.rake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rake index a84ec01b55f..b9b28920e12 100644 --- a/lib/tasks/posts.rake +++ b/lib/tasks/posts.rake @@ -30,14 +30,15 @@ desc 'Rebake all posts matching string/regex' task 'posts:rebake_match', [:pattern, :type] => [:environment] do |_,args| pattern = args[:pattern] type = args[:type] + type = type.downcase if type if !pattern puts "ERROR: Expecting rake posts:rebake_match[pattern,type]" exit 1 end - if type.downcase == "regex" + if type == "regex" search = Post.where("raw ~ ?", pattern) - elsif type.downcase == "string" || !type + elsif type == "string" || !type search = Post.where("raw ILIKE ?", "%#{pattern}%") else puts "ERROR: Expecting rake posts:rebake_match[pattern,type] where type is string or regex"