i have model Store, that has State, City and Neighborhood fields.
i've made an advanced search with searchkick,
but now i want to populate City select_tag with Cities from Stores that has State == State selected in State select tag..
i found grouped_collection, but i dont have a separeted state and city table, just state and city fields in my Store model..
there is any way to make this happen?
ps: sorry for bad english, hope you guys understand
<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)")
end