Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't call attr_readonly on polymorphic belongs_to associations, in c…

…ase it matches the name of some other non-ActiveRecord class/module. [Rick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7748 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 24c2457a26983c323f0c90d175c00453d853f3b6 1 parent 58a5eef
@technoweenie technoweenie authored
View
2  activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Don't call attr_readonly on polymorphic belongs_to associations, in case it matches the name of some other non-ActiveRecord class/module. [Rick]
+
* Try loading activerecord-<adaptername>-adapter gem before trying a plain require so you can use custom gems for the bundled adapters. Also stops gems from requiring an adapter from an old Active Record gem. [Jeremy Kemper, Derrick Spell]
View
2  activerecord/lib/active_record/associations.rb
@@ -844,7 +844,7 @@ def belongs_to(association_id, options = {})
)
module_eval(
- "#{reflection.class_name}.send(:attr_readonly,\"#{cache_column}\".intern) if defined?(#{reflection.class_name})"
+ "#{reflection.class_name}.send(:attr_readonly,\"#{cache_column}\".intern) if defined?(#{reflection.class_name}) && #{reflection.class_name}.respond_to?(:attr_readonly)"
)
end
end
View
4 activerecord/test/fixtures/tagging.rb
@@ -1,3 +1,7 @@
+# test that attr_readonly isn't called on the :taggable polymorphic association
+module Taggable
+end
+
class Tagging < ActiveRecord::Base
belongs_to :tag, :include => :tagging
belongs_to :super_tag, :class_name => 'Tag', :foreign_key => 'super_tag_id'
Please sign in to comment.
Something went wrong with that request. Please try again.