title: In Rails, how to add a new method to String class?
body: <p>I want to build an index for different objects in my Rails project and would like to add a 'count_occurences' method that I can call on String objects.</p>
  
  <p>I saw I could do something like</p>
  
  <pre><code>class String
    def self.count_occurences
      do_something_here
    end
  end
  </code></pre>
  
  <p>What's the exact way to define this method, and where to put the code in my Rails project?</p>
  
  <p>Thanks</p>