word counter example in ruby on rails

Word counter that will count the word in the body of the article and display the total words says something like: Total Words: 12345

I'm guessing you're using .html.erb files. If you've got one for an article that looks something like this:

<%= @article.title %>
<%= @article.content %>

Then, since the stuff between <%=...%> is just ruby code you can simply add a word count like this:

<%= @article.title %>
Number of words: <%= @article.content.scan(/\w+/).size %>
<%= @article.content %>