Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

docs, revisit polymorphic associations with STI example. [ci skip]

This is a follow up to #13926.

/cc @fxn
  • Loading branch information...
commit b7c7cb1a6379f861c04a1273c67fa8b46212f527 1 parent c46b0d1
@senny senny authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 activerecord/lib/active_record/associations.rb
View
7 activerecord/lib/active_record/associations.rb
@@ -669,11 +669,14 @@ def association_instance_set(name, association)
# and member posts that use the posts table for STI. In this case, there must be a +type+
# column in the posts table.
#
+ # Note: The <tt>attachable_type=</tt> method is being called when assigning an +attachable+.
+ # The +class_name+ of the +attachable+ is being passed as a String.
+ #
# class Asset < ActiveRecord::Base
# belongs_to :attachable, polymorphic: true
#
- # def attachable_type=(klass)
- # super(klass.to_s.classify.constantize.base_class.to_s)
+ # def attachable_type=(class_name)
+ # super(class_name.constantize.base_class.to_s)
# end
# end
#

1 comment on commit b7c7cb1

@fxn
Owner

:heart:

Please sign in to comment.
Something went wrong with that request. Please try again.