Perhaps the scope of this method should be restricted to just commentable models by checking if it responds to a commentable method? In the pull request, I used
def find_commentable(commentable_str, commentable_id)
model = commentable_str.constantize
model.respond_to?(:find_comments_for) ? model.find(commentable_id) : nil
end
For example, if we had a User class that was not commentable, then this method could do something like
Perhaps the scope of this method should be restricted to just commentable models by checking if it responds to a commentable method? In the pull request, I used