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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:23:06+00:00 2026-05-27T03:23:06+00:00

scope :unapproved, lambda {|event| where(event_id = ? AND status IS NOT ?, event.id, approved)}

  • 0
scope :unapproved, lambda {|event| where("event_id = ? AND status IS NOT ?",
event.id, "approved")}

The :unapproved scope works with SQLite and MySQL, but it doesn’t work on Heroku where it uses PostgreSQL. I can’t figure out how to make it work with PostgreSQL.

  • 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-27T03:23:07+00:00Added an answer on May 27, 2026 at 3:23 am

    PostgreSQL doesn’t use IS or IS NOT for general comparisons, you want <> or !=:

    where("event_id = ? AND status <> ?", event.id, "approved")
    

    <> should work in MySQL and SQLite as well except when you want to compare against a NULL, then you have to use IS NULL or IS NOT NULL everywhere.

    IS is used for special comparisons such as IS NULL and IS DISTINCT FROM, see the Comparison Operators section of the PostgreSQL manual for further details.

    If you’re planning on deploying on Heroku, you really should be developing on top of PostgreSQL (8.3 for a shared database, 9.0 for a dedicated one). PostgreSQL is a fair bit stricter than SQLite (and MySQL) and no ORM can fully insulate you from the differences between databases. The behavior of GROUP BY is another common problem when moving from SQLite/MySQL to PostgreSQL so you might want to review all you grouping; also, check how you deal with strings that are too long for your varchar columns, AFAIK SQLite ignores your size limits but PostgreSQL will complain loudly if you try to exceed the column size (and MySQL will truncate your data with a mere warning unless you’ve put your server in strict mode).

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

Sidebar

Related Questions

The following scope definition contains two bugs, which causes it not to work as
I have the following scope: scope :comments, :conditions => ['text_value IS NOT NULL'] But
scope issue in PHP classes: Why does this work? class index extends Application {
What exactly is the scope of an HTTP session? I've been googling this but
I've reading scope chain in Javascript but it didn't make any sense to me,
The scope of #define is till the end of the file. But where does
I have this scope: scope :search, lambda {|q| where(name LIKE ?, %#{q}%) } However,
In my application transaction scope is not working for second transaction..It is working fine
I like to scope all of my JQuery functions and event sinks to $(window).load,
Scope: PHP-mysql based site, using memcached. Caching issue is mostly about prices. Because of

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.