title: Parse before storing in MVC
body: <p>I'm getting started with parsing data and getting some structure from user supplied strings (mostly pulling out digits and city names).</p>
  
  <p>I've run a bit of code in the ruby interpreter, and now I want to use that same code in a web application. </p>
  
  <p>I'm struggling as to where in the code my parsing should be, or how it is structured. </p>
  
  <p>My initial instinct was that it belongs in the model, because it is data logic. For example, does the entry have an integer, does it have two integers, does it have a city name, etc. etc.</p>
  
  <p>However, my model would need to inherit both ActiveRecord, and Parslet (for the parsing), and Ruby apparently doesn't allow multiple inheritance.</p>
  
  <p>My current model is looking like this</p>
  
  <pre>
  #concert model
  require 'parslet'
  class concert &lt; Parlset::Parser
    attr_accessible :date, :time, :city_id, :band_id, :original_string
  
     rule(:integer) {match('[0-9]').repeat(1)}
     root(:integer)
  end
  </pre>
  
  <p>Really not much there, but I think I'm stuck because I've got the structure wrong and don't know how to connect these two pieces. </p>
  
  <p>I'm trying to store the original string, as well as components of the parsed data.</p>