Search code examples
ruby-on-railsformssubmitquotesstrip

Problem with Rails stripping quotes from input form


I'm writing a search form for my Rails (2.3.9 but I've checked that this problem exists also on 3.0.3) application. The problem is that Rails is stripping quotation marks from the users input. I would like to give the users possibility to write:

  • "ruby on rails" : and this would search full text for the whole string
  • ruby on rails : this would search for articles with all those three words

But in my controller for both cases I'm getting only one string:

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"=>""}}

Is there any option to skip this stripping the quotation marks?

Remark: When user adds spaces to the both sides for the search string for example: ' "ruby on rails" ' the string will get correctly sent:

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"=>""}}

Solution

  • Seems to be a Rack 1.1 bug: http://thewebfellas.com/blog/2010/7/15/rails-2-3-8-rack-1-1-and-the-curious-case-of-the-missing-quotes