pg_search icon indicating copy to clipboard operation
pg_search copied to clipboard

Nested model search + ActionText

Open alec-c4 opened this issue 5 years ago • 0 comments

Hi! I have several models - Post

class Post
  has_many :comments
  has_rich_text :body

  pg_search_scope :search,
                  against: %i[title],
                  associated_against: {
                    rich_text_body: [:body],
                    comments: {rich_text_body: [:body]}
                  },
                  using: {tsearch: {any_word: true}}
end

and Comment

class Comment
  belongs_to :post
  has_rich_text :body
end

I'd like to perform a search in all threads, to find all posts and comments which contain a search string. With following configuration i can search in posts (but i need to remove comments: {rich_text_body: [:body]}), so how can i configure pg_search_scope to perform search in comments?

alec-c4 avatar Apr 11 '20 20:04 alec-c4