lundi 25 avril 2016

How to write checkbox active record search using using scope

How to do checkbox search through scope in ruby

i have form like this <%VenueCategory.all.each do |c|%> <%= check_box_tag("venue_categories[]", c.id)%> <%= c.name%> <%end%>

i want to search venue categories if more than one option is selected. How to do it with scope

i tried like this in my property.rb model

scope :venue_category, -> (venue_categories) { where venue_category_id: venue_categories }

in my controller @properties = @properties.venue_categories(params[:venue_categories]) if params[:venue_categories].present?

i'm getting error when i tried this. I dont know how to do mulptiple checkbox options search with scope. Please help me if anyone knows. Any help is appreciatable.

Aucun commentaire:

Enregistrer un commentaire