Ruby on rails rails表单中的GET方法
我正在使用搜索表单,希望在RubyonRails表单中使用GET请求。我用这样的东西 1) 鉴于Ruby on rails rails表单中的GET方法,ruby-on-rails,post,get,Ruby On Rails,Post,Get,我正在使用搜索表单,希望在RubyonRails表单中使用GET请求。我用这样的东西 1) 鉴于 form_tag(:action => "actionxyz", :method => "get") 2) 沿途 get 'actionxyz', :controller => :controllerabc 当检查请求时,会看到以下内容 <form accept-charset="UTF-8" action="/actionxyz?method=get" method=
form_tag(:action => "actionxyz", :method => "get")
2) 沿途
get 'actionxyz', :controller => :controllerabc
当检查请求时,会看到以下内容
<form accept-charset="UTF-8" action="/actionxyz?method=get" method="post"><div style="margin:0;padding:0;display:inline">
在url中我看到的更多信息是/actionxyz?method=get
,而不是我提供的搜索字符串。提供的搜索字符串将显示在POST数据中。
这是否意味着rails没有使用GET方法,或者我的解释是错误的。
请澄清..表单标签只需要URL:
form_tag '/actionxyz', :method => "get"
form_标记只需要URL:
form_tag '/actionxyz', :method => "get"
它将方法
get
解释为表单应该到达的路径的一部分,而不是form\u标签的附加选项。因此,您必须将其隔离:
form_tag( {:action => "actionxyz"}, :method => "get") do
或者只是
form_tag url_path, method: :get do #where url_path is your route
它将方法get
解释为表单应该到达的路径的一部分,而不是form\u标签的附加选项。因此,您必须将其隔离:
form_tag( {:action => "actionxyz"}, :method => "get") do
或者只是
form_tag url_path, method: :get do #where url_path is your route