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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:42:59+00:00 2026-06-18T17:42:59+00:00

So this is what I have in my dev (SQLite) environment that works perfectly:

  • 0

So this is what I have in my dev (SQLite) environment that works perfectly:

key = "%#{keywords}%"
listings = Listing.order(:headline)
listings = listings.includes(:neighborhood).where("headline like ? or neighborhoods.name like ?", key, key) if keywords.present?

But, when I try something similar on Heroku, I get a number of errors:

listings = listings.includes(:neighborhood).where("headline like ? or neighborhoods.name like ?", key, key)
ActiveRecord::ConfigurationError: Association named 'neighborhoods' was not found; perhaps you misspelled it?

I also tried the following & got the corresponding error:

> listings = Listing.includes(:neighborhood).where("headline like :keywords or neighborhood.name like :keywords", :keywords => "%#{keywords}%")
  SQL (3.1ms)  SELECT "listings"."id" AS t0_r0, "listings"."listing_category_id" AS t0_r1, "listings"."listing_type_id" AS t0_r2, "listings"."user_id" AS t0_r3, "listings"."boro_id" AS t0_r4, "listings"."neighborhood_id" AS t0_r5, "listings"."building_id" AS t0_r6, "listings"."term_id" AS t0_r7, "listings"."headline" AS t0_r8, "listings"."property_type_id" AS t0_r9, "listings"."unit_num" AS t0_r10, "listings"."common_charges" AS t0_r11, "listings"."taxes" AS t0_r12, "listings"."maintenance" AS t0_r13, "listings"."num_bedrooms" AS t0_r14, "listings"."num_bathrooms" AS t0_r15, "listings"."square_footage" AS t0_r16, "listings"."list_square_footage" AS t0_r17, "listings"."description" AS t0_r18, "listings"."condition_id" AS t0_r19, "listings"."pet_policy_id" AS t0_r20, "listings"."exposure_id" AS t0_r21, "listings"."floor_plan" AS t0_r22, "listings"."photo" AS t0_r23, "listings"."security" AS t0_r24, "listings"."coop_deductible" AS t0_r25, "listings"."flip_tax" AS t0_r26, "listings"."house_families" AS t0_r27, "listings"."house_extensions" AS t0_r28, "listings"."house_stories" AS t0_r29, "listings"."house_units" AS t0_r30, "listings"."created_at" AS t0_r31, "listings"."updated_at" AS t0_r32, "listings"."price" AS t0_r33, "neighborhoods"."id" AS t1_r0, "neighborhoods"."name" AS t1_r1, "neighborhoods"."created_at" AS t1_r2, "neighborhoods"."updated_at" AS t1_r3, "neighborhoods"."boro_id" AS t1_r4 FROM "listings" LEFT OUTER JOIN "neighborhoods" ON "neighborhoods"."id" = "listings"."neighborhood_id" WHERE (headline like '%prospect heights%' or neighborhood.name like '%prospect heights%')
ActiveRecord::StatementInvalid: PG::Error: ERROR:  missing FROM-clause entry for table "neighborhood"
LINE 1: ..._id" WHERE (headline like '%prospect heights%' or neighborho...
                                                             ^
: SELECT "listings"."id" AS t0_r0, "listings"."listing_category_id" AS t0_r1, "listings"."listing_type_id" AS t0_r2, "listings"."user_id" AS t0_r3, "listings"."boro_id" AS t0_r4, "listings"."neighborhood_id" AS t0_r5, "listings"."building_id" AS t0_r6, "listings"."term_id" AS t0_r7, "listings"."headline" AS t0_r8, "listings"."property_type_id" AS t0_r9, "listings"."unit_num" AS t0_r10, "listings"."common_charges" AS t0_r11, "listings"."taxes" AS t0_r12, "listings"."maintenance" AS t0_r13, "listings"."num_bedrooms" AS t0_r14, "listings"."num_bathrooms" AS t0_r15, "listings"."square_footage" AS t0_r16, "listings"."list_square_footage" AS t0_r17, "listings"."description" AS t0_r18, "listings"."condition_id" AS t0_r19, "listings"."pet_policy_id" AS t0_r20, "listings"."exposure_id" AS t0_r21, "listings"."floor_plan" AS t0_r22, "listings"."photo" AS t0_r23, "listings"."security" AS t0_r24, "listings"."coop_deductible" AS t0_r25, "listings"."flip_tax" AS t0_r26, "listings"."house_families" AS t0_r27, "listings"."house_extensions" AS t0_r28, "listings"."house_stories" AS t0_r29, "listings"."house_units" AS t0_r30, "listings"."created_at" AS t0_r31, "listings"."updated_at" AS t0_r32, "listings"."price" AS t0_r33, "neighborhoods"."id" AS t1_r0, "neighborhoods"."name" AS t1_r1, "neighborhoods"."created_at" AS t1_r2, "neighborhoods"."updated_at" AS t1_r3, "neighborhoods"."boro_id" AS t1_r4 FROM "listings" LEFT OUTER JOIN "neighborhoods" ON "neighborhoods"."id" = "listings"."neighborhood_id" WHERE (headline like '%prospect heights%' or neighborhood.name like '%prospect heights%')

I also tried and got the following error:

0> listings = Listing.joins(:neighborhood).where("headline like :keywords or neighborhood.name like :keywords", :keywords => "%#{keywords}%")
  Listing Load (2.7ms)  SELECT "listings".* FROM "listings" INNER JOIN "neighborhoods" ON "neighborhoods"."id" = "listings"."neighborhood_id" WHERE (headline like '%prospect heights%' or neighborhood.name like '%prospect heights%')
ActiveRecord::StatementInvalid: PG::Error: ERROR:  missing FROM-clause entry for table "neighborhood"
LINE 1: ..._id" WHERE (headline like '%prospect heights%' or neighborho...
                                                             ^
: SELECT "listings".* FROM "listings" INNER JOIN "neighborhoods" ON "neighborhoods"."id" = "listings"."neighborhood_id" WHERE (headline like '%prospect heights%' or neighborhood.name like '%prospect heights%')

Thoughts?

Thanks.

Edit 1:

A listing belongs_to neighborhood, and neighborhood has_many listings.

Edit 2:

Extracted one of the SQL statements and ran it via psql, this is the result:

SELECT "listings".* FROM "listings" INNER JOIN "neighborhoods" ON "neighborhoods"."id" = "listings"."neighborhood_id" WHERE (headline like '%prospect heights%' or neighborhood.name like '%prospect heights%');                                                                                                                                                                 
ERROR:  missing FROM-clause entry for table "neighborhood"
LINE 1: ..._id" WHERE (headline like '%prospect heights%' or neighborho...
  • 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-18T17:43:01+00:00Added an answer on June 18, 2026 at 5:43 pm

    Try the below:

    listings = Listing.includes(:neighborhood).where("listings.headline like :keywords or neighborhoods.name like :keywords", :keywords => "%#{keywords}%")
    

    I think it should call listings.headline instead of headline

    SELECT "listings".* FROM "listings" INNER JOIN "neighborhoods"   
    ON "neighborhoods"."id" = "listings"."neighborhood_id"  
    WHERE (
    headline like '%prospect heights%'               #I mean here
    or neighborhood.name like '%prospect heights%')  #also here, should be neighborhoods.name 
    

    EDIT – do you know that there are some difference between SQLite and PostgreSQL? I faced a similar problem. I think you want ILIKE instead of LIKE:

    listings = Listing.includes(:neighborhood).where("listings.headline ilike :keywords or neighborhoods.name ilike :keywords", :keywords => "%#{keywords}%")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails app that's databases are in SQLite (The dev and production).
For testing purposes I have this shell script #!/bin/bash echo $$ find / >/dev/null
I have a page with photo gallery http://dev.dolina-imeniy.ru/fotogalereya/kp_usadba_tishnevo/ I use this to bind click
I am pretty new to this iPhone dev thing but so far I have
Just like in this topic , I have a performance issue in dev mode
I'm updating an sqlite database to have a new column bin that is filled
I have a remote database (at the moment sqlite, but eventually mysql) that I
I have a simple django app that is using only the admin. This is
I have a large sqlite db. Its 185mb. This query is taking about 5seconds
I have been developing an application that required the SQLite database file to be

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.