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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:37:17+00:00 2026-06-13T00:37:17+00:00

Two models: User has_one :location, as: locatable Location belongs_to :locatable, polymorphic: true So far

  • 0

Two models:

User has_one :location, as: locatable
Location belongs_to :locatable, polymorphic: true

So far so good. Now say I want to find a User with a certain name and city:

User.joins(:location).where(name: 'Eddie Explosion', location: { city: 'Kaboom' })

…but when I run that, boom,

ActiveRecord::StatementInvalid: PG::Error: ERROR: missing FROM-clause entry for table “location”.

Any idea what’s going on here / how to fix this? Can’t seem to figure it out.

  • 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-13T00:37:20+00:00Added an answer on June 13, 2026 at 12:37 am

    I can’t really experiment on the exact case you have, but I have done something similar to what you want to do in my application, here is an example below:

    User.joins(:locations).where("users.name = 'Eddie Explosion' AND locations.city = 'Kaboom'")
    

    Cheers :))

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

Sidebar

Related Questions

I have two models, referral and user model. Referral belongs_to User AND user has_one
I have two models. class User has_one :spec, :dependent => :destroy # returns true
I have two models: User (email:string) Profile (name:string) class User < ActiveRecord::Base has_one :profile
Two models (Rails 2.3.8): User; username & disabled properties; User has_one :profile Profile; full_name
Two models (Rails 2.3.8): User; username & disabled properties; User has_one :profile Profile; full_name
I have two models, TreeNode and User. Each user has_one TreeNode, which is the
I'm working on an association between two models: class Person < ActiveRecord::Base belongs_to :user
I have two models user and profile. I want to save the username and
I am using acts-as-taggable on. Two models: User and Posts. Posts belongs_to :user User
I have two models: User and Store class Store < ActiveRecord::Base belongs_to :user class

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.