Does anyone know how to use composed_of to pull data from multiple classes (tables)? I know how to use composed_of to aggregate columns within the same table but am running in to trouble pulling from two tables.
The example below works but I don't want to see standard.strand_id, I want to see strand.name (which is in the Strand table, not the Standard table).
class Standard < ActiveRecord::Base composed_of :full_standard, :mapping => [ %w[grade grade], %w[strand_id strand_id] %w[number number] ]
class FullStandard < ActiveRecord::Base attr_reader :grade, :strand_id, :number
def initialize(grade, strand, number) @grade = grade @strand_id = strand_id @number = number end
def to_s [ @grade, @strand_id, @number ].compact.join(" ") end end
Again, this works, BUT I don't want to see the strand_id, I want to see strand.name (a column in the Strand table--not the Standard table)
Also, here are the table relationships:
class Standard belongs_to :strand
class Strand has_many :standards
Thank you!!!