Is there a way to use pg_search stone faces

I would like to use faces in the plus of standard search. Is there a way to make the search results themselves β€œsearch” using faces using pg_search?

As far as I can tell, pg_search_scope are mutually exclusive (is there a workaround?). Thanks!

Example:

1) search blogs with the word "test"

2) click on the link to get only articles from the previous result that were also submitted to june

+6
source share
1 answer

I am the original author and supporter of pg_search .

A pg_search_scope works like any other Active Record area, so you can connect them.

So, let's say you have a Blog model with pg_search_scope named search_title and another area named in_month that takes two parameters, a month number and a year number. Something like that:

 class Blog < ActiveRecord::Base include PgSearch pg_search_scope :search_title, :against => :title scope :in_month, lambda { |month_number, year_number| where(:month => month_number, :year => year_number) } end 

Then you can call it like this:

 Blog.search_title("broccoli").in_month(6, 2011) 

The converse should also work:

 Blog.in_month(6, 2011).search_title("broccoli") 

And pagination options, such as Kaminari, could also be named at the end.

+8
source

Source: https://habr.com/ru/post/899706/


All Articles