From 9b92f437cb8ac663e53b2693edec743ddb2c60dc Mon Sep 17 00:00:00 2001 From: monocle Date: Thu, 28 Oct 2010 10:04:30 -0700 Subject: [PATCH] Check for commentable model in Comment.find_commentable --- lib/comment_methods.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/comment_methods.rb b/lib/comment_methods.rb index 0c4ef0f..16d8369 100644 --- a/lib/comment_methods.rb +++ b/lib/comment_methods.rb @@ -29,8 +29,9 @@ def find_comments_for_commentable(commentable_str, commentable_id) # Helper class method to look up a commentable object # given the commentable class name and id def find_commentable(commentable_str, commentable_id) - commentable_str.constantize.find(commentable_id) - end + model = commentable_str.constantize + model.respond_to?(:find_comments_for) ? model.find(commentable_id) : nil + end end end end