<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -11,21 +11,7 @@ module ActiveRecord
         end
         
         def acts_as_taggable_on(*args)
-          self.class_eval do
-            @tag_types = args
-            def self.tag_types
-              @tag_types
-            end
-            
-            has_many :taggings, :as =&gt; :taggable, :dependent =&gt; :destroy, :include =&gt; :tag
-            has_many :base_tags, :class_name =&gt; &quot;Tag&quot;, :through =&gt; :taggings, :source =&gt; :tag
-            
-            attr_writer :custom_contexts
-            
-            before_save :save_cached_tag_list
-            after_save :save_tags
-          end
-          
+          puts &quot;Registering #{args.inspect} with #{self.inspect}&quot;
           for tag_type in args
             tag_type = tag_type.to_s
             self.class_eval do
@@ -34,8 +20,6 @@ module ActiveRecord
               has_many &quot;#{tag_type}&quot;.to_sym, :through =&gt; &quot;#{tag_type.singularize}_taggings&quot;.to_sym, :source =&gt; :tag
             end
             
-            include ActiveRecord::Acts::TaggableOn::InstanceMethods
-            
             self.class_eval &lt;&lt;-RUBY
               def self.caching_#{tag_type.singularize}_list?
                 caching_tag_list_on?(&quot;#{tag_type}&quot;)
@@ -64,12 +48,31 @@ module ActiveRecord
               def find_related_#{tag_type}(options = {})
                 related_tags_on('#{tag_type}',options)
               end
+              alias_method :find_related_on_#{tag_type}, :find_related_#{tag_type}
             RUBY
-          end
-          
-          extend ActiveRecord::Acts::TaggableOn::SingletonMethods          
+          end      
           
-          alias_method_chain :reload, :tag_list
+          if respond_to?(:tag_types)
+            puts &quot;Appending #{args.inspect} onto #{tag_types.inspect}&quot;
+            write_inheritable_attribute(:tag_types, tag_types + args)
+          else
+            self.class_eval do
+              write_inheritable_attribute(:tag_types, args)
+              class_inheritable_reader :tag_types
+            
+              has_many :taggings, :as =&gt; :taggable, :dependent =&gt; :destroy, :include =&gt; :tag
+              has_many :base_tags, :class_name =&gt; &quot;Tag&quot;, :through =&gt; :taggings, :source =&gt; :tag
+            
+              attr_writer :custom_contexts
+            
+              before_save :save_cached_tag_list
+              after_save :save_tags
+            end
+            
+            include ActiveRecord::Acts::TaggableOn::InstanceMethods
+            extend ActiveRecord::Acts::TaggableOn::SingletonMethods                
+            alias_method_chain :reload, :tag_list
+          end
         end
         
         def is_taggable?</diff>
      <filename>lib/active_record/acts/taggable_on.rb</filename>
    </modified>
    <modified>
      <diff>@@ -33,6 +33,23 @@ describe &quot;acts_as_taggable_on&quot; do
     end
   end
   
+  context &quot;inheritance&quot; do
+    before do
+      @taggable = TaggableModel.new(:name =&gt; &quot;taggable&quot;)
+      @inherited_same = InheritingTaggableModel.new(:name =&gt; &quot;inherited same&quot;)
+      @inherited_different = AlteredInheritingTaggableModel.new(:name =&gt; &quot;inherited different&quot;)
+    end
+    
+    it &quot;should pass on tag contexts to STI-inherited models&quot; do
+      @inherited_same.should respond_to(:tag_list, :skill_list, :language_list)
+      @inherited_different.should respond_to(:tag_list, :skill_list, :language_list)
+    end
+    
+    it &quot;should have tag contexts added in altered STI models&quot; do
+      @inherited_different.should respond_to(:part_list)
+    end
+  end
+  
   context &quot;reloading&quot; do
     it &quot;should save a model instantiated by Model.find&quot; do
       taggable = TaggableModel.create!(:name =&gt; &quot;Taggable&quot;)</diff>
      <filename>spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -88,4 +88,31 @@ describe &quot;Taggable&quot; do
     bob.save
     TaggableModel.find_tagged_with(&quot;spinning&quot;, :on =&gt; :rotors).should_not be_empty
   end
+  
+  context &quot;inheritance&quot; do
+    before do
+      @taggable = TaggableModel.new(:name =&gt; &quot;taggable&quot;)
+      @inherited_same = InheritingTaggableModel.new(:name =&gt; &quot;inherited same&quot;)
+      @inherited_different = AlteredInheritingTaggableModel.new(:name =&gt; &quot;inherited different&quot;)
+    end
+    
+    it &quot;should be able to save tags for inherited models&quot; do
+      @inherited_same.tag_list = &quot;bob, kelso&quot;
+      @inherited_same.save
+      InheritingTaggableModel.find_tagged_with(&quot;bob&quot;).first.should == @inherited_same
+    end
+    
+    it &quot;should find STI tagged models on the superclass&quot; do
+      @inherited_same.tag_list = &quot;bob, kelso&quot;
+      @inherited_same.save
+      TaggableModel.find_tagged_with(&quot;bob&quot;).first.should == @inherited_same
+    end
+    
+    it &quot;should be able to add on contexts only to some subclasses&quot; do
+      @inherited_different.part_list = &quot;fork, spoon&quot;
+      @inherited_different.save
+      InheritingTaggableModel.find_tagged_with(&quot;fork&quot;, :on =&gt; :parts).should be_empty
+      AlteredInheritingTaggableModel.find_tagged_with(&quot;fork&quot;, :on =&gt; :parts).first.should == @inherited_different
+    end
+  end
 end
\ No newline at end of file</diff>
      <filename>spec/acts_as_taggable_on/taggable_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
 
 describe &quot;Tagger&quot; do
   before(:each) do
-    @user = User.new
+    @user = TaggableUser.new
     @taggable = TaggableModel.new(:name =&gt; &quot;Bob Jones&quot;)
   end
   </diff>
      <filename>spec/acts_as_taggable_on/tagger_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,9 +15,10 @@ ActiveRecord::Schema.define :version =&gt; 0 do
   
   create_table :taggable_models, :force =&gt; true do |t|
     t.column :name, :string
+    t.column :type, :string
     #t.column :cached_tag_list, :string
   end
-  create_table :users, :force =&gt; true do |t|
+  create_table :taggable_users, :force =&gt; true do |t|
     t.column :name, :string
   end
 end</diff>
      <filename>spec/schema.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,9 +6,17 @@ ActiveRecord::Base.logger = Logger.new(plugin_spec_dir + &quot;/debug.log&quot;)
 load(File.dirname(__FILE__) + '/schema.rb')
 
 class TaggableModel &lt; ActiveRecord::Base
-  acts_as_taggable_on :tags, :languages, :skills
+  acts_as_taggable_on :tags, :languages
+  acts_as_taggable_on :skills
 end
 
-class User &lt; ActiveRecord::Base
+class InheritingTaggableModel &lt; TaggableModel
+end
+
+class AlteredInheritingTaggableModel &lt; TaggableModel
+  acts_as_taggable_on :parts
+end
+
+class TaggableUser &lt; ActiveRecord::Base
   acts_as_tagger
 end
\ No newline at end of file</diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e488a0040ec1def0b6406ae2afb11f18e14ab6b6</id>
    </parent>
  </parents>
  <author>
    <name>Michael Bleigh</name>
    <email>michael@intridea.com</email>
  </author>
  <url>http://github.com/mbleigh/acts-as-taggable-on/commit/1bedda907e62d6574a7c2bc6ee73558b7ac078f6</url>
  <id>1bedda907e62d6574a7c2bc6ee73558b7ac078f6</id>
  <committed-date>2008-06-09T12:04:15-07:00</committed-date>
  <authored-date>2008-06-09T12:04:15-07:00</authored-date>
  <message>Added support and specs for Single Table Inheritance. Thanks to slainer68 for the patch! [#5 status:resolved]</message>
  <tree>309aa2ff9a467db1e17cfae267a3ed49c1a4f833</tree>
  <committer>
    <name>Michael Bleigh</name>
    <email>michael@intridea.com</email>
  </committer>
</commit>
