Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Apparently AR doesn't really save the serialized aggregation, although the model seems to be perfectly aware of it.
class Prizes < Struct.new(:c1,:c2)
end
class Draw < ActiveRecord::Base
composed_of :prizes, :mapping => Prizes.members
end
draw = Draw.new
p Draw.column_names.include? "prizes"
# => true
draw.prizes = Prizes.new(1,2)
draw.save!
p draw.prizes
# => #<struct Prizes c1=1, c2=2>
p draw[:prizes]
# => nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment