Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7052789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:25:33+00:00 2026-05-28T03:25:33+00:00

Good day! I use pg_search to implement Full text searching in my web app.

  • 0

Good day!

I use pg_search to implement Full text searching in my web app. I created form where user print his data and then i try to show it but result always empty! What is wrong?

/views/users/index.html.erb

<%= render 'shared/search_form' %>  
<%= will_paginate %>   
  <ul class="users">  
     <%= render @users %>       
  </ul>   
<%= will_paginate %>

/views/shared/_search_form.erb

<% search_id_attr = :q %>
<%= form_tag( users_path, :method => "get" ) do %>
  <%= label_tag( search_id_attr, "Search for:" ) %>
  <%= text_field_tag( search_id_attr ) %>
  <%= submit_tag("Search", :name => nil ) %>
<% end %>

/controllers/users_controller.rb

class UsersController < ApplicationController  
  ...
  def index
    @title = "All users"
    @users = PgSearch.multisearch( params[:q] ).paginate( :page => params[:page] )
  end
...
end

UPD1: After editing in /controllers/users_controller.rb I have params[:q]. Now i get such error:

ActionView::Template::Error (Missing partial pg_search/documents/document with {:handlers=>[:erb, :builder, :coffee], :formats=>[:html], :locale=>[:en, :en]}. Searched in:
  * "/Users/iUser/rails_projects_terminal/sample_app/app/views"
):
    6: <%= will_paginate %>
    7: 
    8: <ul class="users">
    9:  <%= render @users %>                                                                                                    
    10: </ul>
    11: 
    12: <%= will_paginate %>
  app/views/users/index.html.erb:9:in `_app_views_users_index_html_erb__3107215974202561754_70174719087800'

UPD2: I created empty partial views/pg_search/documents/_document and now i just don’t have any results.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:25:34+00:00Added an answer on May 28, 2026 at 3:25 am

    I’m the author of pg_search.

    You ought to rename your variable from @users to @pg_search_documents, because PgSearch.multisearch always returns objects of type PgSearch::Document, not User.

    Then you will want to do something like this in your view:

    <%= render 'shared/search_form' %>  
    <%= will_paginate %>   
    <ul class="users">
      <%= @pg_search_documents.each do |pg_search_document| %>
        <%= render pg_search_document.searchable %>  
      <%= render @users %>       
    </ul>   
    <%= will_paginate %>
    

    This is because multisearch was designed for searching across multiple models.

    If you want to make a search that only searches User, then you should instead use pg_search_scope to build a search scope directly on the User class. For example:

    class User < ActiveRecord::Base
      include PgSearch
      pg_search_scope :search_by_name, :against => [:name]
    end
    
    User.search_by_name("ExR") # => returns an Active Record scope of `User` objects.
    

    Let me know if this isn’t clear. I know that the documentation has grown a bit large and should be simplified and organized so that developers have a better chance of understanding the subtleties.

    Thanks!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good Day, My web app is set to use Windows Authentication and Impersontation is
Good day! In his Effective STL Scott Meyers wrote A third is to use
Good day. I try to use jqGrid in my web project. everything is good
Good Day all, I want to use datepicker to show the user particular dates
Good day! I've the following ViewModel class I use for login form: using System.ComponentModel.DataAnnotations;
Good day, I am sending e-mail with php and I use user's session for
Good day, I have a library project that i use to create a paid
I've read that It's a good experience to use a fresh image every day
Good day. In my Drupal site, strange characters appear in text. Like, instead of
Good day all I have the following question: I would like to use Chart

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.