Ashley Moran
2006-Nov-04 17:53 UTC
How does the polymorphic #{as}_type attribute get set in ActiveRecord models?
Hi people I''m stumped. I''ve been playing with a little patch to the ActiveRecord inheritance, and it''s broke a test, namely this one from associations/join_models_test.rb: def test_polymorphic_has_many_create_model_with_inheritance_and_custom_base_ class post = SubStiPost.create :title => ''SubStiPost'', :body => ''SubStiPost body'' assert_instance_of SubStiPost, post tagging = tags(:misc).taggings.create(:taggable => post) assert_equal "SubStiPost", tagging.taggable_type end It''s failing with <"SubStiPost"> expected but was <"Post">. I''ve deduced that "taggable_type" is stored as an attribute of the join model in has_many :through associations, but I can''t work out how it is calculated or set. Is there an AR guru who can explain this bit to me? Thanks Ashley --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---