[英]Using ransack for Rails application material dropdown select in view
Just need to know how you add ransack code in rails view as I m taking array list as category items and passing into the bootstrap material 当我将数组列表作为类别项并传递到引导材料中时,只需要知道如何在Rails视图中添加ransack代码即可
the code for rails Rails的代码
on top of starting line search path code 在起始行搜索路径代码之上
<%= search_form_for @search, url: events_path do |f| %>
dropdown code dropdown without ransack which gives output with correct dropdown list 下拉代码下拉菜单(不带acksack),可提供具有正确下拉列表的输出
<div class="col">
<div class="dropdown" id="dropdown">
<p class="selected" id="selected"><span>Filter By Category1</span> <i class="material-icons">keyboard_arrow_down</i></p>
<ul class="dropdown-list" id="dropdown-list">
<a href="/events">
<li>All Events </li>
<% @category_list.each do |cat| %>
<li class="selected" id="list"> <%= cat.name %></li>
<% end %>
</ul>
</div>
</div>
I m trying to add ransack this does not display my list 我正在尝试添加ransack,这不会显示我的列表
<div class="col">
<div class="dropdown" id="dropdown">
<%= f.select :category_name_eq, class: "selected" %>
<ul class="dropdown-list" id="dropdown-list">
<a href="/events">
<li>All Events </li>
<% @category_list.each do |cat| %>
<li class="selected" id="list"> <%= cat.name %></li>
<% end %>
</ul>
</div>
</div>
you can do with list like this below, 您可以使用以下列表进行操作,
in case you allow blank option you should add include_blank: true as sample below 如果允许空白选项,则应添加include_blank:true,如下所示
<div class="row form-group">
<%= f.label "Filter By Category1 <i class="mi md-18">arrow_downward</i>".html_safe, :class => 'col-form-label col-sm-3' %>
<div class="col-sm-9">
<%= f.select :category_name_eq,
@category_list.all.map { |cat| [cat.name, cat.name] },
{ include_blank: true }, { class: 'form-control' } %>
</div>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.