title: guidelines for where to put classes in Rails apps that don't fit anywhere
body: <p>I'm wondering if there are any best practices about where to put non-standard Ruby files in Rails apps, those that don't fit in any of the default directories (<code>controllers</code>/<code>models</code> etc.). </p>
  
  <p>I'm talking about classes that are used by controllers/models etc., but are not subclasses of any of the Rails base classes. Classes that include functionality extracted from models to make them less fat. Some of them kind of look like models but aren't AR models, some of them look more like "services", some are something in between or something else.</p>
  
  <p>A few random examples:</p>
  
  <ul>
  <li>"strategy" classes that handle authentication with password, via facebook etc.</li>
  <li>"XParams" objects that encapsulate params or "XCreator" objects that handle processing of params to execute some complex action that results in creating some AR models in the end</li>
  <li>classes that make requests to external APIs or encapsulate those requests and responses</li>
  <li>fake models that can be substituted for a real AR model (e.g. guest user)</li>
  <li>Resque jobs</li>
  <li>classes that store and read information from Redis</li>
  <li>classes that execute some specific actions like processing data, generating reports etc. and are called from Resque jobs or rake tasks</li>
  </ul>
  
  <p>I've got quite a lot of these now, some of them are added to <code>lib</code> which ends up as a pile of random classes and modules, some sneak into <code>app/models</code>. I'd like to organize this somehow, but I don't know where to start.</p>
  
  <p>Should only AR models go into <code>app/models</code>? Or is it ok to also put there any domain or helper models? How you decide if something is a model?</p>
  
  <p>Should everything that doesn't fit into <code>app</code> go into <code>lib</code>? Or maybe I should add a few new custom subdirectories to <code>app</code>? What subdirectories, and how do I divide the custom classes?</p>
  
  <p>How do you handle this in your projects? I know every project is a bit different, but there must be some similarities.</p>