Skip to content

Allow for Commentables to be STI inherited classes #24

Merged
merged 2 commits into from Mar 23, 2012
View
2 acts_as_commentable_with_threading.gemspec
@@ -1,4 +1,4 @@
-ACTS_AS_COMMENTABLE_WITH_THREADING = Gem::Specification.new do |s|
+Gem::Specification.new do |s|
s.name = "acts_as_commentable_with_threading"
s.version = "1.1.1"
s.date = "2011-12-08"
View
2 lib/acts_as_commentable_with_threading.rb
@@ -28,7 +28,7 @@ module SingletonMethods
# Helper method to lookup for comments for a given object.
# This method is equivalent to obj.comments.
def find_comments_for(obj)
- Comment.where(:commentable_id => obj.id, :commentable_type => obj.class).order('created_at DESC')
+ Comment.where(:commentable_id => obj.id, :commentable_type => obj.class.base_class).order('created_at DESC')
end
# Helper class method to lookup comments for
View
2 lib/generators/acts_as_commentable_upgrade_migration/comment.rb
@@ -17,7 +17,7 @@ class Comment < ActiveRecord::Base
def self.build_from(obj, user_id, comment)
c = self.new
c.commentable_id = obj.id
- c.commentable_type = obj.class.name
+ c.commentable_type = obj.class.base_class.name
c.body = comment
c.user_id = user_id
c
View
2 lib/generators/acts_as_commentable_with_threading_migration/templates/comment.rb
@@ -17,7 +17,7 @@ class Comment < ActiveRecord::Base
def self.build_from(obj, user_id, comment)
c = self.new
c.commentable_id = obj.id
- c.commentable_type = obj.class.name
+ c.commentable_type = obj.class.base_class.name
c.body = comment
c.user_id = user_id
c
Something went wrong with that request. Please try again.