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 8429203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:16:11+00:00 2026-06-10T05:16:11+00:00

I am building a rails app where users can post, must like a form.

  • 0

I am building a rails app where users can post, must like a form. I want users to be able to search through the posts with a text field, and then all records will be returned where the post content is similar to the user query. For example, a user enters:

'albert einstein atomic bomb'

Then, I want a to run a query where every word is checked, along with the query itself. Something like:

query_result = Hash.new
query_result << Post.where('content ILIKE ?', "%albert%")
query_result << Post.where('content ILIKE ?', "%einstein%")
query_result << Post.where('content ILIKE ?', "%atomic%")
query_result << Post.where('content ILIKE ?', "%bomb%")
query_result << Post.where('content ILIKE ?', "%albert einstein atomic bomb%")

This will not work of course, but I hope you get the idea. Any and all input would be appreciated.

  • 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-06-10T05:16:14+00:00Added an answer on June 10, 2026 at 5:16 am

    You can use sunspot gem for stuff like this. Once it’s setup you can do searches like so

    # Posts with the exact phrase "great pizza"
    Post.search do
      fulltext '"great pizza"'
    end
    
    # One word can appear between the words in the phrase, so "great big pizza"
    # also matches, in addition to "great pizza"
    Post.search do
      fulltext '"great pizza"' do
        query_phrase_slop 1
      end
    end
    

    and more. See the info in the link.

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

Sidebar

Related Questions

I'm building a Rails 3 app where users can select one of a number
I am using Rails 3, and building an app in which a user can
I'm building a rails gallery app for a company that doesn't want to host
I'm currently building a Rails app, where a user can upload an mp3 and
I'm building an app in Rails that allows users to upload images to their
I am building a Rails app that will allow users to publish their location
Im building a Rails app, and there are two models that I want to
Newbie to Rails. I am building an app where users create events at a
While building a Rails app, I recently encountered a situation in which I want
I am building an rails app and I want to secure the user's downloads.

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.