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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:15:58+00:00 2026-06-17T10:15:58+00:00

Does pushing an entity to a it’s parent collection causes the collection to be

  • 0

Does pushing an entity to a it’s parent collection causes the collection to be loaded?

e.g.:

Parent.childs << a_child

Is the parent.childs “array” now loaded with ALL the childs or just “a_child” ? i.e. will a SQL “select * from childs where parent_id = ?” statement will be executed before adding to the collection?

EDIT:

http://apidock.com/rails/v3.2.3/ActiveRecord/Associations/CollectionAssociation/concat_records seems to call “add_target” BEFORE calling “insert_record” which adds the entity to the @target array…

  • 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-17T10:15:59+00:00Added an answer on June 17, 2026 at 10:15 am

    No (thank god)! Parent.childs is a Proxy and ‘<<‘ will just trigger the creation/update of a_child

    More info on How do rails association methods work?

    Also in the rails comments of associations/collection_associations.rb

    You need to be careful with assumptions regarding the target: The
    proxy does not fetch records from the database until it needs them,
    but new ones created with +build+ are added to the target. So, the
    target may be non-empty and still lack children waiting to be read
    from the database. If you look directly to the database you cannot
    assume that’s the entire collection because new records may have been
    added to the target, etc.

    A quick check on my console confirmed there the children aren’t loaded.

    parent.children << child; nil
    

    => only parent and child where loaded….

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

Sidebar

Related Questions

I have a really light ViewController, it does nothing in viewDidLoad. I'm pushing this
I'm having a problem with pushing an object into an array. Here's my object
Why does $a become an arrayref? I'm not pushing anything to it. perl -MData::Dumper
When pushing to our shared bare repository (over ssh), the post-commit does not work
I have the following code, which does a nice animation when pushing a new
When pushing a new value onto an indexed array $array[] = 'new value'; the
Why does the session Id need to be updated at all in CodeIgniter. I
I'm having trouble with a JavaScript array adding an extra undefined object after pushing
Does anyone know if there is a way to generate different code in the
Does COUNT(*) have any significant impact for MySQL performance if query already has GROUP

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.