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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:36:17+00:00 2026-06-04T15:36:17+00:00

Lets say I have a project model which has many members and many tasks.

  • 0

Lets say I have a project model which has many members and many tasks.

class Project < ActiveRecord::Base
  has_many :memberships
  has_many :members, :through => :memberships, :class_name => 'User'
  has_many :tasks
end

When a task is created in the project, we keep a record of which user created it. Only users who are a member of the current project can

class Task < ActiveRecord::Base
  belongs_to :creator, :class_name => 'User'
  belongs_to :project
end

In my projects#show action, I want to find a project and display it along with it’s members, tasks and their creators. I try to eager load these things in order to speed up the query.

Since I am eager loading the searches members, and tasks can only have a creator who is a member, am I right in thinking that I don’t have to include the task’s creator specifically?

In other words, can I do this:

Search.includes(:members, :tasks)

or should I do this:

Search.includes(:members, :tasks => :creator)
  • 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-04T15:36:18+00:00Added an answer on June 4, 2026 at 3:36 pm

    I think you will need to explicitly include :creator otherwise it will query for it when you access the creator, because there is no way rails can know that creator is one of the already queried members

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

Sidebar

Related Questions

Lets say we have a Company model, that has many Employees And has many
Let's say I have a model class called Project, but instead of this: class
lets say i have classA which is a class of audio,that sample the audio
I have two models lets say: class superfields(Model): fieldA = models.FloatField() fieldB = models.FloatField()
Hey, Let's say I have this model: class Log: msg = CharField(...) project =
I am using Hibernate with my Spring MVC project. Lets say my model has
Let's say I have a project that is a class library. I have a
Lets say have this immutable record type: public class Record { public Record(int x,
Let's say I have a model foo, and my model has a publish! method
Rails newbie here and I'm stumped. In Rails I have a Project Model which

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.