Skip to content

Commit

Permalink
Check for commentable model in Comment.find_commentable
Browse files Browse the repository at this point in the history
  • Loading branch information
CapyTheBeara committed Oct 28, 2010
1 parent 0a8ed7d commit 9b92f43
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/comment_methods.rb
Expand Up @@ -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

0 comments on commit 9b92f43

Please sign in to comment.