I have following Association;
class Package < ActiveRecord::Base
has_many : modules
end
class Module < ActiveRecord::Base
belongs_to : package
end
And I use this to get records from the join;
@recs = Package.includes(:modules).where( 'name' => 'abc-pkg').all
But the resultset, @recs, include only parent table’s (package) columns. How can I get child (module) table’s column?
PS: Using PostgreSQL 9.1 and gem ‘pg’ adapter
Thank you.
That is actually correct. You will not see the child’s columns inside the
@recsvariable when inspecting it. The point of theincludesmethod is to avoid additional queries when iterating over the packages and asking forpackage.modules.