Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
# this fixes polymorphic assignment relationships so the _type field is set when you assign an object to the association. module ActiveRecord module Associations class BelongsToPolymorphicAssociation < AssociationProxy #:nodoc: def replace_with_assignment_anyways(record) replace_without_assignment_anyways(record) record && @owner[@reflection.options[:foreign_type]] = record.class.base_class.name.to_s end alias_method_chain :replace, :assignment_anyways end end end
Pasted May 13, 2008 8:29PM EDT