Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed up class stored when commentable is an sti inherited class

  • Loading branch information...
commit 20395f391af6fdad946cf549fae88a2715d270c6 1 parent 084e206
@arjun810 arjun810 authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.