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

  • Home
  • SEARCH
  • 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 8062817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:48:03+00:00 2026-06-05T10:48:03+00:00

I am having a issue using active record conditions in rails 2 with postgres.

  • 0

I am having a issue using active record conditions in rails 2 with postgres. My problem is when ever I try to use this query (I am using geokit, but that is not the issue)

Table.all(:conditions => ["id IN (?)", id_array.join(",")], :origin => origin, :within => 20)

I get this problem:

ActiveRecord::StatementInvalid: PG::Error: ERROR:  invalid input syntax for integer: "21,28"
LINE X: ...OM "tables" WHERE (((id IN (E'21,28...

Why is it putting the “E'” in there and how to I get rid of it?

  • 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-05T10:48:05+00:00Added an answer on June 5, 2026 at 10:48 am

    With id_array.join(","), you pass a single string to the function. As all strings get escaped and surrounded by single quotes when put into the generated SQL query, you naturally get the SQL error, as in this IN statement you can only use comma-separated integers.

    The simple solution is to directly pass an array to the function. ActiveRecord then creates the correct values in SQL on its own. You can use it like this:

    Table.all(:conditions => ["id IN (?)", id_array], :origin => origin, :within => 20)
    

    Alternatively, you could use this even more ruby-like syntax which produces the exact same SQL query:

    Table.all(:conditions => {:id => id_array}, :origin => origin, :within => 20)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue starting the MySQL server using MAMP, and the problem may
I am having a issue using Google's SDC (Secure Data Connector) with my Google
I'm having an issue using the Cookie class of the Servlet API 2.5 on
I'm having an issue using the qTip plugin with jQuery. I've created a js
I believe I am having a memory issue using numpy arrays. The following code
I'm having an issue where I'm using the camera app to take a photo
i'm having a little issue with doctrine using symfony 1.4 (I think it's using
I am having an issue with a website developed using ASP.Net/C# sometimes taking all
I am having an issue where I am using regex.Replace to replace part of
I'm having an issue accessing some nested data in an XML response using Perl/XML::Simple.

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.