Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

Query inside of ActiveRecord Observer generated incorrect SQL

#4632

The Problem

For a model class, 'NodeArgument', I am calling NodeArgument.all inside of an observer for the NodeArgument model and instead of returning all NodeArguments, it is only returning a subset of them.

The Setup:

Model Classes:
Node

has_many :node_arguments

Node Arguments

belongs_to :node

An Observer with after_correct.

Triggering the issue

I have a Node object and call @node.node_arguments.find_or_create_by_name(...)
This successfully creates the Node Argument and triggers the observer's after_create method.

Result

In the observer I am using NodeArgument.all. From the log, I can see that they query being generated has a where clause of node_id = .

Expected Result

I would expect the NodeArgument.all method to behave like normal. It seems to be a reentrancy problem to me.

Reported by cilcoder · May 17th, 2010 @ 11:33 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Rohit Arondekar
    Rohit Arondekar
    • Tag changed from activerecord associations, aciverecord, find, observers to aciverecord, activerecord, associations, find, observers

    October 7th, 2010 @ 05:21 AM

  2. David Trasbo
    David Trasbo
    • State changed from new to incomplete
    • Importance changed from to Low

    Please provide a patch with a failing test and/or a fix.

    October 8th, 2010 @ 09:00 AM

  3. Santiago Pastorino
    Santiago Pastorino
    • State changed from incomplete to open

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:58 PM

  4. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:58 PM