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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:19:58+00:00 2026-06-16T07:19:58+00:00

I have following Association; class Package < ActiveRecord::Base has_many : modules end class Module

  • 0

I have following Association;

class Package < ActiveRecord::Base
  has_many : modules
end

class Module < ActiveRecord::Base
  belongs_to : package
end

And I use this to get records from the join;

@recs = Package.includes(:modules).where( 'name' => 'abc-pkg').all

But the resultset, @recs, include only parent table’s (package) columns. How can I get child (module) table’s column?

PS: Using PostgreSQL 9.1 and gem ‘pg’ adapter

Thank you.

  • 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-16T07:19:59+00:00Added an answer on June 16, 2026 at 7:19 am

    That is actually correct. You will not see the child’s columns inside the @recs variable when inspecting it. The point of the includes method is to avoid additional queries when iterating over the packages and asking for package.modules.

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

Sidebar

Related Questions

I have the following association: class Resource < ActiveRecord::Base belongs_to :author def self.search(search) where('title
I have the following models: class Instance < ActiveRecord::Base has_many :users has_many :books end
I have the following model: class Advisor < ActiveRecord::Base belongs_to :course end class Course
I have the following in /app/models: class Area < ActiveRecord::Base has_many :locations end class
I have the following code class Involvement < ActiveRecord::Base belongs_to :matter belongs_to :contact end
Imagine I have the following models: class Translation < ActiveRecord::Base has_many :localizations end class
I have the following models: class Price < ActiveRecord::Base belongs_to :product end class Metric
I have the following three models: class User < ActiveRecord::Base has_many :associations has_many :pharmacies,
I currently have the following models: class Player < ActiveRecord::Base belongs_to :team belongs_to :user
I have got the following models, class City < ActiveRecord::Base belongs_to :state belongs_to :country

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.