Rails Edge - Associations not loading

This has probably been covered before, but I hadn’t found much of a
fix. I have two tables, one with has_many, and another with belongs_to.
When I do user = User.find 1, it doesn’t pull up User.notes, it says
it’s “not loaded yet”. How do I fix this? I remember reading something
about it when I first ran across edge, but lost the location. Any help
would be fantastic.

On Wed, Dec 06, 2006 at 07:35:33PM -0000, mrkris wrote:

This has probably been covered before, but I hadn’t found much of a
fix. I have two tables, one with has_many, and another with belongs_to.
When I do user = User.find 1, it doesn’t pull up User.notes, it says
it’s “not loaded yet”. How do I fix this? I remember reading something
about it when I first ran across edge, but lost the location. Any help
would be fantastic.

Maybe what you want is:

    User.find(1, :include => [ :notes ])


Cheers,

  • Jacob A.

On 12/6/06, mrkris [email protected] wrote:

This has probably been covered before, but I hadn’t found much of a
fix. I have two tables, one with has_many, and another with belongs_to.
When I do user = User.find 1, it doesn’t pull up User.notes, it says
it’s “not loaded yet”. How do I fix this? I remember reading something
about it when I first ran across edge, but lost the location. Any help
would be fantastic.

Do anything else with user.notes to load it, such as user.notes.to_a, or
force load it with user.notes(true).

This issue will be fixed shortly.

jeremy

Sounds good. Thanks Jeremy + Jacob, you answered my question :slight_smile: