Permalink
Browse files

Fixed up class stored when commentable is an sti inherited class

  • Loading branch information...
1 parent 084e206 commit 20395f391af6fdad946cf549fae88a2715d270c6 @arjun810 committed Feb 22, 2012
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

0 comments on commit 20395f3

Please sign in to comment.