Skip to content

Instantly share code, notes, and snippets.

@txus
Created November 15, 2010 10:57
Show Gist options
  • Save txus/700258 to your computer and use it in GitHub Desktop.
Save txus/700258 to your computer and use it in GitHub Desktop.
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