app/models/wall_comment.rb
# Return the person for the thing commented on.
# For example, for blog post comments it's the blog's person
# For wall comments, it's the person himself.
Return the person for the thing commented on.
For example, for blog post comments it's the blog's person
For wall comments, it's the person himself.
Return the person for the thing commented on . For example for blog post comments it ' s the blog ' s person For wall comments it ' s the person himself .
def commented_user
    @commented_user ||= case commentable.class.to_s
                          when "User"
                            commentable
                          when "BlogPost"
                            if commentable.blog.owner_type == "User"
                              commentable.blog.owner
                            elsif commentable.blog.owner_type == "Group"
                              commentable.blog.owner.owner
                            end
                          when "Photo"
                            if commentable.owner_type == "User"
                              commentable.owner
                            elsif commentable.owner_type == "Group"
                              commentable.owner.owner
                            end
                          when "Event"
                            commentable.user
                          when "Group"
                            commentable.owner
                          when "NewsItem"
                            commentable.creator
                          end
  end
def commented_user @commented_user ||= case commentable . class . to_s when "User" commentable when "BlogPost" if commentable . blog . owner_type == "User" commentable . blog . owner elsif commentable . blog . owner_type == "Group" commentable . blog . owner . owner end when "Photo" if commentable . owner_type == "User" commentable . owner elsif commentable . owner_type == "Group" commentable . owner . owner end when "Event" commentable . user when "Group" commentable . owner when "NewsItem" commentable . creator end end
Return the person for the thing commented on.
Return the person for the thing commented on .