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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:28:59+00:00 2026-06-09T17:28:59+00:00

UsersController’s index: @users = current_user.other_users.where(first_name like ?, %#{params[:q]}%) 1) Search works fine in the

  • 0

UsersController’s index:

@users = current_user.other_users.where("first_name like ?", "%#{params[:q]}%")

1) Search works fine in the text field except that the first character isn’t detected.

Example: If I search with “J” for “John” I won’t get any results, but if I do “o” I will get “John” as I should.

2) I’m wondering how you add an additional search condition above for last_name…?
I thought something like

.where("first_name like ? or last_name like ?", "%#{params[:q]}%")

would work, but it doesn’t…

Help 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-09T17:29:01+00:00Added an answer on June 9, 2026 at 5:29 pm

    I’m betting you’re using Postgres as your database, where LIKE clauses are case-sensitive. To search case-insensitive in Postgres:

    .where("first_name ILIKE ? or last_name ILIKE ?", "%#{params[:q]}%")
    

    This SO has plenty of background: How do you write a case insensitive query for both MySQL and Postgres?

    Other alternatives:

    • https://github.com/texticle/texticle
    • store lowercase version of full_name and search on that field
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to have an Index action for a Users controller that takes an
Suppose this is my users controller:- class UsersController < ApplicationController def show @user =
In CakePHP 2.0 version, I have written something like this in UsersController.php public function
Started GET /users/new for 127.0.0.1 at 2010-07-11 23:07:03 -0400 Processing by UsersController#new as HTML
I want the following structure in my ASP.NET MVC solution; Controllers/HomeController.cs Controllers/Administration/AdministrationController.cs Controllers/Administration/UsersController.cs Views/Home/Index.aspx
i have a controller page like this: class UsersController extends AppController { var $helpers
The current request for action 'Index' on controller type 'UsersController' is ambiguous between the
If one where to have a controller named UsersController with an action like: public
The title pretty much says it all. I would like to test e.g. UsersController::admin_index()
I have a UsersController , with OnException (which works), but if I make the

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.