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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:21:06+00:00 2026-06-13T18:21:06+00:00

Is it possible to call the include? function on a whole table, like this?

  • 0

Is it possible to call the include? function on a whole table, like this?

<% @user.games.each do |g|
   @@latestround = g.rounds.order('created_at DESC').first
%>
    <% if @@latestround.submittedpictures.isFinalPicture.include?(true) %>
        <p>FinalPicture has been played!</p>
    <% end %>
<% end %>

The problem i’m getting is that It only works when I put a block on submittedpictures and then loop through each record of this table. However I want to look through the whole table in one go and see if the column ‘isFinalPicture’ includes a value with ‘false’.

Any ideas?

The following snippet works but its not the way i want it (I would get more lines if the round happens to have more ‘true’ FinalPictures)

<% @@latestround.submittedpictures.each do |s| %>
    <% if s.isFinalPicture == true %>
         <p>Final Picture has been played!</p>
    <% end %>
<% end %>
  • 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-13T18:21:08+00:00Added an answer on June 13, 2026 at 6:21 pm

    You could make a scope for it like

    class SubmitedPricture << ActiveRecord::Base
    
      scope :final_pictures, where('isFinalPricture = ?', true)
    end
    

    then you could see if there is any with only one query

    latestround.submittedpictures.final_pictures.any?
    

    Also you should follow the conventions of Rails in naming your Models and everything else. Like submittedpictures should be submitted_pictures

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

Sidebar

Related Questions

Possible Duplicate: Why does the Execution Plan include a user-defined function call for a
It is possible to call a table-valued function directly, or do I need to
Possible Duplicates: Undefined Behavior and Sequence Points Order of function call I have found
is it possible to call a C++ function from FORTRAN such as #include <iostream.h>
It's possible to call C functions through CREATE FUNCTION but how can .NET functions
I would like to call the C function fabs(double); numerous times in my program,
How is it possible that this function below inserts two rows in my database?
I like the results of this code but i was curious, is it possible
Is it possible to use std::for_each or anything else like that ? #include <list>
Possible Duplicate: What will happen when I call a member function on a NULL

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.