我正在尝试在我的游戏过滤器中添加“任何”部分。在广泛的视图中它工作正常我只是重新加载页面传递链接其他需要的参数,如下所示:
<%= link_to games_path difficulty: params[:difficulty], category: params[:category] do %>
<div class="game-type-select-content-item">
<h3>Any</h3>
</div>
<% end %>
但是,在我的移动视图中,我使用的是 form_with 助手:
<%= form_with url: "/games", method: :get, local: true, data: {target: "game-filters.form"} do |f| %>
<%= f.label :language, "Language:", :class => "font-bold" %>
<%= f.select(:language, options_for_select(Language.all.pluck(:name, :language_code), selected: params[:language]), {}, {data: {action: "change->game-filters#submit"}}) %>
<%= f.label :difficulty, "Difficulty:", :class => "font-bold" %>
<%= f.select(:difficulty, options_for_select(Game.difficulties.keys, selected: params[:difficulty]), {}, {data: {action: "change->game-filters#submit"}}) %>
<%= f.label :category, "Category:", :class => "font-bold" %>
<%= f.select(:category, options_for_select(Game.categories.keys, selected: params[:category]), {}, {data: {action: "change->game-filters#submit"}}) %>
<% end %>
有没有办法给每个选项一个“任何”,而不是重置其他功能?