On Feb 28, 1:57 am, Arpit Jain <[email protected]> wrote:
> So what's the solution to that Fred ? I would have to load question also
> when I load the subquestion ? That would mean doing a different query twice
> for extracting the same object. Or is there any other way around ?
>
There isn't really  good solution. There's a plugin that attempts to
address this (parental_control), or you can fiddle around making ar
believe it has already loaded it. The ar_context plugin can also be
helpful in this context.
You can also make your include load it (ie :include => {:subquestion
=> :question} but that always seems a bit messy.
You also do things semi manually ie instead of referencing
foo.question, collect all the questions into a hash indexed by id and
access your_hash[foo.question_id]

Fred
> On Sat, Feb 28, 2009 at 5:15 AM, Frederick Cheung <
>
> [email protected]> wrote:
>
> > On Feb 27, 5:58 pm, Arpit Jain <[email protected]> wrote:
> > > Can anyone explain to me the sql query done in the last step :
>
> > >http://pastie.org/402200
>
> > Because activerecord isn't super smart in this way and doesn't fill in
> > associations bidirectionally when they are loaded.
>
> > Fred
>
> > > --
> > > Arpit Jain
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to