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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:15:47+00:00 2026-05-27T17:15:47+00:00

I am using the rails3-jquery-autocomplete gem to autocomplete the a field (product) in a

  • 0

I am using the rails3-jquery-autocomplete gem to autocomplete the a field (product) in a form in my rails 3 app. The user can either type in the product name or the product code, which are both string columns in the products table.
Everything works fine locally, but on heroku the ajax request crashes with the standard 500 heroku error:

We're sorry, but something went wrong (500)

I think this might be a postgre / sql issue – I use mysql locally for development but heroku runs on a postgre sql database, and I am doing the following query in the function that gets calles by the ajax autocomplete request:

  def get_autocomplete_items(parameters)
    items = Product.select("DISTINCT CONCAT_WS(' ', product_code, title, id) AS full_name, product_code, title, id").where(["CONCAT_WS(' ', product_code, title) LIKE ?", "%#{parameters[:term]}%"])
  end

Locally, this would return me an array on json format including all matching produc_ids and names:

[{"id":"9","label":"xt-pnt-dress_45 - Catherine Malandrino","value":"xt-pnt-dress_45 - Catherine Malandrino"}, ... ]

If anybody has an idea how to change that query that it conforms with heroku or any others idea I’d be really grateful. thx.

  • 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-27T17:15:47+00:00Added an answer on May 27, 2026 at 5:15 pm

    Heroku uses PostgreSQL 8.3 for shared databases and 9.0 for dedicated databases. Neither version 8.3 nor version 9.0 have a concat_ws function, that function is only available in version 9.1+.

    You can concatenate the strings by hand though:

    items = Product.select("DISTINCT product_code || ' ' || title || ' ' || id AS full_name, product_code, title, id").where(["product_code || ' ' || title LIKE ?", "%#{parameters[:term]}%"])
    

    That will work as long as none of product_code, title, and id are NULL. If you might have NULLs then you can wrap them COALESCE (e.g. COALESCE(product_code || ' ', '')) to turn them into empty strings.

    Alternatively, you could take care of the full_name in Ruby:

    def full_name
        [product_code, title, id].reject(&:blank?).join(' ')
    end
    

    and have a separate generated column for the LIKE or check both columns with LIKE:

    where('product_code LIKE ? OR title LIKE ?', "%#{parameters[:term]}%", "%#{parameters[:term]}%")
    where('produce_code LIKE :pat OR title LIKE :pat', :pat => "%#{parameters[:term]}%")
    

    Also, you should be aware that MySQL’s LIKE is case insensitive but PostgreSQL’s is not so you might want to downcase everything to avoid confusion:

    where('LOWER(product_code) LIKE :pat OR LOWER(title) LIKE :pat', :pat => "%#{parameters[:term].downcase}%")
    

    Since || is a logical-OR in MySQL, joining the three strings in Ruby (i.e. def full_name) and checking product_code and title with separate downcased LIKEs is probably the cleanest portable solution.

    Switching your development environment to PostgreSQL would also be a good idea, matching versions with your deployment environment would also be a good idea. There are other differences that will cause trouble.

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

Sidebar

Related Questions

I'm using the rails3-jquery-autocomplete gem to autocomplete the name of a user, search attribute
In Rails, I'm using rails3-jquery-autocomplete gem to autocomplete the username owner on a photos#edit
I'm using 'rails3-jquery-autocomplete' gem, but it doesn't have multi column search, but there is
Is it possible to select DISTINCT values using Rails3 JQuery autocomplete gem?
Using: jquery3-autocomplete gem at 1.0.5 jquery-rails gem at 1.0.19 mysql2 gem at 0.2.7 The
I'm Using Rails3 and the Unobstrusive Javascript Gem jquery-rails . Remote deletion (without page
I am using the JQuery Autocomplete UI with my rails app and it is
I'm using auto_complete plugin: https://github.com/crowdint/rails3-jquery-autocomplete I have installed the gem and added require line
Using Rails 3.1.1. & 'rails3-jquery-autocomplete' I think this question should be quite simple for
I am developing an autocomplete form using JQuery and Rails. However I don't know

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.