aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrhenium <re4k@re4k.info>2013-05-31 23:37:51 +0900
committerrhenium <re4k@re4k.info>2013-05-31 23:37:51 +0900
commit90abe9df522b3fafdf83e0578d6ee3fac58905a5 (patch)
tree3818b5571ff997228442c4e3ad2eb0b59b8a6efc
parent85424b0c01fe508ffdfa8e38e4423853986d7451 (diff)
downloadaclog-90abe9df522b3fafdf83e0578d6ee3fac58905a5.tar.gz
fix search#search error when no "query" parameter
-rw-r--r--app/controllers/search_controller.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index aa13660..96396c8 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -3,16 +3,16 @@ class SearchController < ApplicationController
def search
@caption = "search"
- @tweets = Tweet.where(parse_query(params[:query])).reacted.recent(7).order_by_id.list(params, force_page: true)
+ @tweets = Tweet.where(parse_query(params[:query] || "")).reacted.recent(7).order_by_id.list(params, force_page: true)
end
private
def parse_query(input)
str = input.dup
strings = []
- str.gsub!(/"((?:\\"|[^"])*?)"/) {|m| strings << $1; "##{strings.size - 1}" }
+ str.gsub!(/"((?:\\"|[^"])*?)"/) {|m| strings << $1; " ##{strings.size - 1} " }
groups = []
- while str.sub!(/\(([^()]*?)\)/) {|m| groups << $1; "$#{groups.size - 1}" }; end
+ while str.sub!(/\(([^()]*?)\)/) {|m| groups << $1; " $#{groups.size - 1} " }; end
conv = -> s do
s.scan(/\S+(?: OR \S+)*/).map {|co|