Ruby on Rails Wednesday, January 27, 2016

Hi
this code:

  x = Project.where('status=?','active').eager_load(:tasks)


produces a nice query, in sql everythig is ok, all columns have been alias as t0_r1,....


but how do i access it? my loops are failing when tryin to access the associates attribute:

  x = Project.where('status=?','active').eager_load(:tasks)
     x.each do |rec|
      p rec.id #<< OK
      p rec.tasks.id # << OUCH
    end


pls advise

thx



--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMeihBiH9Lz_Px%3DbUJ%3DoxM6-3Ez2iCxL6p-y1ftoyyPvxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment