搜索 RequestURITooLarge 时出错 ruby

Error RequestURITooLarge searching ruby

事情是这样的:我的表单中有多个搜索字段。但是当我尝试进行多次搜索时出现错误 RequestURITooLarge ...我想知道是否存在避免此问题的方法。每次填写文本框或日期字段时增加 url 并收到错误。我还尝试了一个重置​​按钮,但只是清理了文本字段。这里的代码让您了解我使用的方法,也许会以某种方式帮助您。谢谢!!

View_item

def self.search(s_codigo, s_den_cont, s_marca)
where("codigo ilike :s_c and den_cont ilike :s_d and marca ilike :s_m", s_c: "%#{s_codigo}%", s_d: "%#{s_den_cont}%", s_m: "%#{s_marca}%")
end

#Search section #2  

def self.search_fec_min(s_codigo, s_den_cont, s_marca, s_fec_min)
where("codigo ilike :s_c and den_cont ilike :s_d and marca ilike :s_m and date_expired >= :s_fmin", s_c: "%#{s_codigo}%", s_d: "%#{s_den_cont}%", s_m: "%#{s_marca}%", s_fmin: "#{s_fec_min}")
end  

索引

<%= text_field_tag :s_codigo, params[:s_codigo], placeholder: "Search for cod" %>
<%= text_field_tag :s_den_cont, params[:s_den_cont], placeholder: "Search for Denominación" %>
<%= text_field_tag :s_marca, params[:s_marca], placeholder: "Search brand" %>
<%= date_select :s_fec_min, params[:s_fec_min], placeholder: "Search for date", :include_blank => true %>  

控制器

if self.is_date(params[:s_fec_min])
@items = View_item.all.order("date_expired ASC").page(params[:page]).per(15).search_fec_min(params[:s_codigo], params[:s_den_cont], params[:s_marca], params[:s_fec_min])     
  elsif (params[:s_codigo] != "" or params[:s_den_cont] != "" or params[:s_marca] != "")
@items = View_item.all.order("date_expired ASC").page(params[:page]).per(15).search(params[:s_codigo], params[:s_den_cont], params[:s_marca])
  else
@items = View_item.all.order("date_expired ASC").page(params[:page]).per(15)
end  

MAX_URI_LENGTH 为 webrick 服务器设置为仅 2083 个字符。访问长度超过此限制的 url 会引发 WEBrick::HTTPStatus::RequestURITooLarge 异常。

尝试切换到不同的服务器:

#Gemfile
gem 'thin'

$bundle install 
$ rails s

=> Booting Thin
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.6.3 codename Protein Powder)
Maximum connections set to 1024
Listening on localhost:3000, CTRL+C to stop