Re: [Rails] how do i access attriutes when using eager_load has_many

2016-01-27 Thread tom
ok, if i do this then i can acces the associated records: x = Project.where('status=?','active').eager_load(:tasks) x.each do |rec| p rec.id #<< OK rec.tasks each do |y| p y.id end end i guess i was just expecting a flat table because thats

Re: [Rails] how do i access attriutes when using eager_load has_many

2016-01-27 Thread tom
ok, u r right - i was just frustrated because i was going back and forth between joins , includes etc - here the 'error' undefined method `id' for # p rec.tasks.id On Wed, Jan 27, 2016 at 1:06 PM, Hassan Schroeder < hassan.schroe...@gmail.com> wrote: > On Wed, Jan 27, 2016 at 9:49 AM, tom wrot

Re: [Rails] how do i access attriutes when using eager_load has_many

2016-01-27 Thread Hassan Schroeder
On Wed, Jan 27, 2016 at 9:49 AM, tom wrote: > x = Project.where('status=?','active').eager_load(:tasks) > 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| >

[Rails] how do i access attriutes when using eager_load has_many

2016-01-27 Thread tom
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