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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:41:11+00:00 2026-05-25T20:41:11+00:00

What is the best way to write a Rails query that returns records that

  • 0

What is the best way to write a Rails query that returns records that are at least 5 minutes old? I am using Rails 3.0.1, Ruby 1.9.2 and PostgreSQL. At the moment I have this:

Note.order('date DESC').where('private_note = ? AND (?-created_at) > 300',false, Time.now.utc)

which gets these errors:

Note Load (0.7ms)  SELECT "notes".* FROM "notes" WHERE (private_note = 'f' AND ('2011-09-28 01:07:30.094475'-created_at) > 300) ORDER BY date DESC
PGError: ERROR:  operator does not exist: interval > integer
LINE 1: ...'f' AND ('2011-09-28 01:07:30.094475'-created_at) > 300) ORD...
                                                             ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT     "notes".* FROM       "notes"  WHERE     (private_note = 'f' AND ('2011-09-28 01:07:30.094475'-created_at) > 300) ORDER BY  date DESC
Completed   in 214ms

ActiveRecord::StatementInvalid (PGError: ERROR:  operator does not exist: interval > integer
LINE 1: ...'f' AND ('2011-09-28 01:07:30.094475'-created_at) > 300) ORD...
                                                             ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT     "notes".* FROM       "notes"  WHERE     (private_note = 'f' AND ('2011-09-28 01:07:30.094475'-created_at) > 300) ORDER BY  date DESC):
  app/controllers/notes_controller.rb:17:in `public_stream_get_notes'

A sample created_at value is 2011-09-28 01:00:01 UTC

  • 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-25T20:41:12+00:00Added an answer on May 25, 2026 at 8:41 pm
    Note.where('created_at <= ?', 5.minutes.ago).where(:private_note => false).order('date DESC')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What's the best way to write a supybot plugin in ruby? Or other language
What is the best way to write a function (or something DSLish) that will
I would like to write a Ruby on Rails application that consumes a RESTful
My last post was on the best way to write a SQL query with
What is the best way to write a dynamic parametrized query for sql server
What's the best way to write an application in order to get it working
Whats the best way to read/write file properties (like author, description, etc) in C#?
What is the best way to read and write .INI files in .NET? It
I need to write AVL-tree with generic type in C. The best way I
I am using a rails helper that creates 3 select lists for the purpose

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.