我正在为我的 Rails(2.3.9 但我已经检查过这个问题在 3.0.3 上也存在)应用程序编写了一个搜索表单。问题是 Rails 正在从用户输入中去除引号。我想给用户写的可能性:
- "ruby on rails" :这将搜索整个字符串的全文
- ruby on rails :这将搜索包含所有这三个单词的文章
但是在我的控制器中,对于这两种情况,我只得到一个字符串:
Processing NewsController#index (for 127.0.0.1 at 2010-11-23 10:23:15) [GET]
Parameters: {"action"=>"index", "controller"=>"news", "search"=>{"category"=>"", "news_agency"=>"", "fullsearch"=>"ruby on rails", "order"=>""}}
是否有任何选项可以跳过此剥离引号?
备注: 当用户在搜索字符串的两边添加空格时,例如:“ruby on rails”,字符串将被正确发送:
Processing NewsController#index (for 127.0.0.1 at 2010-11-23 10:23:15) [GET]
Parameters: {"action"=>"index", "controller"=>"news", "search"=>{"category"=>"", "news_agency"=>"", "fullsearch"=>" \"ruby on rails\" ", "order"=>""}}