This is a review page of the school curriculum scoring system. I want to do the following:
1. Count the number of words in each comment
2. when the whole loop is over, count the total number of words in all comments
<div id=”header”>
<h1>Course Rating Information </h1>
<p>
Number:
<%= @course.number %>
</p>
<p>
Year:
<%= @course.year %>
</p>
<p>
Name:
<%= @course.name %>
</p>
</div>
<div id=”pagebody”>
<% if @course.comments.exists? %>
<h2>Ratings</h2>
<% @course.comments.each do |comment| %>
<p>
<strong>Commenter:</strong>
<%= comment.commenter %>
</p>
<p>
<strong>Comment:</strong>
<%= comment.comment %>
</p>
<% end %>
<% else %>
<h2>No ratings available</h2>
<% end %>
</div>
<div id=”footer”>
<%= link_to ‘New Comment’, new_course_comment_path(@course) %>
<%= link_to ‘Back to course listing’, courses_path %>
</div>
@course.comments.sum{ |cc| cc.comment.length }