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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:09:42+00:00 2026-06-06T07:09:42+00:00

In my model I would like to create a scope that takes advantage of

  • 0

In my model I would like to create a scope that takes advantage of a method that is also in my model.

I have the following model method:

  def is_paired
    ! pairing_id.nil?
  end

I would like to make a scope that looks something like this

  scope :paired, where(:is_paired => true)

But when I do I get an error:

SQLite3::SQLException: no such column: participants.is_paired: SELECT "participants".* F...

How can I create a scope that takes advantage of a method in my model???

  • 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-06T07:09:45+00:00Added an answer on June 6, 2026 at 7:09 am

    You cannot. Basically methods used in scopes like where, order ect. are “translated” to sql queries. Rails doesn’t know how to translate custom methods to sql queries.
    Anyway you can use the following approach: scope :paired, where('pairing_id IS NOT NULL')
    For more details you can check: Rails where condition using NOT NULL

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

Sidebar

Related Questions

I have a model, I would like create a thumbnail by ImageMagick( yes with
I have a model containing products. I would like to create a search form
I would like to create a Group model in Google App Engine and then
I would like to create model binding functionality so a user can enter ','
I have a DateTimeField called created in my model and I would like to
I have this array property in my model and would like to see it
I would like to create a custom action filter attribute that adds a value
I would like to create an application that would use the same system as
I would like to create an observer which will observe only one custom method.
In my asp.net MVC 3 project I would like to create a contact that's

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.