Tag Search with Ransack

I use Ransack to do fairly complex searches across some models. One of these patterns contains free text and uses act_as_taggable labels to label words.

I am trying to create a collection selector of these words so that ransack can find any of the full text entries from a subset of tags that the user can define.

I am almost absent here, but if I try to choose more than one word, it will not return any results!

= f.select :note_in, @freetexts.tag_counts_on(:tags), {}, {:multiple => true}
+5
source share
2 answers

Ransack is not really targeted at complex searches. It is very likely that if you emphasize sufficient validation, you end up with a more complex problem if you make difficult choices.

recomment Sequel, ransack .

, : Ransack .

0

, , ransack, , act-as-taggable-on:

@search = MyModel.ransack(params[:q])
@result = @search.result(distinct: true).includes(:related_model)
@result = @result.tagged_with(params[:tags].split(/\s*,\s*/)) if params[:tags].present?
@result = @result.paginate(page: params[:page], per_page: 20)

: , Ransack. , Ransack.

0

All Articles