need some help on ransack filtering.
I have model Project, which has many tags through acts_as_taggable gem.
Project.rb:
class Project < ActiveRecord::Base
include PublicActivity::Common
belongs_to :customer
belongs_to :category
has_many :attachments, :as => :attachable
has_many :reports, :dependent => :destroy
has_many :messages, :dependent => :destroy
has_many :screens, :dependent => :destroy
accepts_nested_attributes_for :attachments, :allow_destroy => true
acts_as_taggable
end
so the @project.tags - works in console just fine.
However, I have advanced search form with ransack gem on index page, and
i
need to filter projects depending on tags which are selected by user. So
that only projects which have all of the selected tags were displayed.
Also a have categories, projects belong to categories. So the checkboxes
for categories work as expected. But how can i do checkboxes for tags?
Here’s my form for search:
= search_form_for @search do |f|
- @categories.each do |category|
= check_box_tag('q[category_id_eq_any][]', category.id)
= category.name
= f.text_field :budjet_gteq
= f.text_field :budjet_lteq
- @tags.each do |tag|
= check_box_tag('q[tags_id_eq_all][]', tag.id)
= tag.name
That’s what i have in console after submiting the form (so i have no
tags
query at all, even though i checked two checkboxes):
Processing by ProjectsController#index as HTML
Parameters: {"utf8"=>"✓", "q"=>{"category_id_eq_any"=>["1"],
“budjet_gteq”=>“100000”, “budjet_lteq”=>“70000000”}}
Any help will be appreciated.