Skip to content

Instantly share code, notes, and snippets.

@x37v
Created February 3, 2011 20:20
Show Gist options
  • Save x37v/810119 to your computer and use it in GitHub Desktop.
Save x37v/810119 to your computer and use it in GitHub Desktop.
class Foo < ActiveRecord::Base
has_many :bars
end
class Bar < ActiveRecord::Base
belongs_to :foo, :polymorphic => true #is polymorphic even needed?
end
class Baz < Bar
end
foo = Few.new
foo.bars << Baz.new
foo.save
#gives me 'Bar'
foo.bars.each do |b|
puts b.class
end
#i'm finding that i need to do this
foo.bars.reload.each do |b|
puts b.class
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment