我有模型商店,有州,城市和邻里字段。
我使用searchkick进行了高级搜索,
但现在我想在城市选择标签中填充城市中的城市,这些城市在州选择标签中选择了州==州。
我找到了groups_collection,但我没有separeted州和市表,只是我的商店模型中的州和城市字段..
有什么方法可以实现这一目标吗?
ps:抱歉英语不好,希望你们理解
<div class="col-sm-3 col-md-3">
<div class="form-group">
<select class="form-control" name="state" id="state" title="Select Category">
<%= @states.each do |selectstate| %>
<option value="<%= selectstate.state%>"><%= selectstate.state%></option>
<%end%>
</select>
</div><!-- /.form-group -->
</div><!-- /.col-* -->
<div class="col-sm-3 col-md-3">
<div class="form-group">
<select class="form-control" name="state" id="state" title="Select Category">
<%= @cities.each do |selectcity| %>
<option value="<%= selectcity.city%>"><%= selectcity.city%></option>
<%end%>
</select>
</div><!-- /.form-group -->
</div><!-- /.col-* -->
def index
search = params[:search].presence || "*"
conditions = {}
conditions[:state] = params[:state] if params[:state].present?
conditions[:city] = params[:city] if params[:city].present?
conditions[:neighborhood] = params[:neighborhood] if params[:neighborhood].present?
@stores = Store.search search, where: conditions, aggs: [:city, :state, :neighborhood], smart_aggs: false
@states = Store.select("DISTINCT(STATE)")
@cities = Store.select("DISTINCT(CITY)")
@neighborhoods = Store.select("DISTINCT(NEIGHBORHOOD)")
端