i want to search both category and location on click on search(Ransack)
my view
<%= form_tag location_path, :method=>'get' do %>
<%= select_tag :q, options_from_collection_for_select(Category.all, :id, :name, params[:q]) %>
<%= text_field_tag :q, nil,:placeholder=>"Tell us what you are looking for.." %>
<input type="submit" value="SEARCH" class="btn1 home-search-button" >
<% end %>
This is my view of this form my searchcontroller is
def location
q = params[:q]
@key=q
@property = Property.ransack(location_or_category_name_cont: q).result(distinct: true)
end
this search searches only location not category,
on executing i am getting like this,
`url is like this : http://localhost:3000/location?utf8=%E2%9C%93&q=2&q=banglore`
command iam getting on executing ` Here it is searching banglore as category name and location(it should search 'commercial' as category_name(which is under category_id:2) instaed of banglore'
Any help is appreciatable
Aucun commentaire:
Enregistrer un commentaire