无法将 form_tag 方法设置为 get
Cannot set form_tag method as get
我试着用这样的 get 方法发送 form_tag
= form_tag search_offers_path, method: :get, class: 'sort-form form inputs-underline' do
.sort-inputs
.input-group.inputs-underline.min-width-150px.sort-input
= label_tag :sort_by, 'Sort by'
= select_tag :sort_by, options_for_select([["Sort by", ""], ["User level", "user_level"], ["Success rating", "user_average_overall_rating"]]), class: "form-control"
.input-group.inputs-underline.min-width-150px.sort-input
= label_tag :sort_direction, 'Sort direction'
= select_tag :sort_direction, options_for_select([["Sort direction", ""], ["Ascending", "asc"], ["Descending", "desc"]]), class: "form-control"
但我不明白为什么它会变成 POST 作为 form_tag 默认
Started POST "/offers/search" for 127.0.0.1 at 2018-01-04 12:35:18 +0700
ActionController::RoutingError (No route matches [POST] "/offers/search"):
有人有提示吗?
更新:我检查了根据反馈生成的 HTML 并看到 data-remote = true(尽管我从未设置过它而且我也不想要 ajax 请求).
<%= form_tag({}, {:method => :get, class: 'sort-form form inputs-underline'}) do %>
试试这个。你一定能得到你的解决方案。
我试着用这样的 get 方法发送 form_tag
= form_tag search_offers_path, method: :get, class: 'sort-form form inputs-underline' do
.sort-inputs
.input-group.inputs-underline.min-width-150px.sort-input
= label_tag :sort_by, 'Sort by'
= select_tag :sort_by, options_for_select([["Sort by", ""], ["User level", "user_level"], ["Success rating", "user_average_overall_rating"]]), class: "form-control"
.input-group.inputs-underline.min-width-150px.sort-input
= label_tag :sort_direction, 'Sort direction'
= select_tag :sort_direction, options_for_select([["Sort direction", ""], ["Ascending", "asc"], ["Descending", "desc"]]), class: "form-control"
但我不明白为什么它会变成 POST 作为 form_tag 默认
Started POST "/offers/search" for 127.0.0.1 at 2018-01-04 12:35:18 +0700
ActionController::RoutingError (No route matches [POST] "/offers/search"):
有人有提示吗?
更新:我检查了根据反馈生成的 HTML 并看到 data-remote = true(尽管我从未设置过它而且我也不想要 ajax 请求).
<%= form_tag({}, {:method => :get, class: 'sort-form form inputs-underline'}) do %>
试试这个。你一定能得到你的解决方案。