title: How I can modularize Rails model?
body: <p>I'm implementing several classes which does not have data by itself, just logics. These classes implements access control policy to date which depends on several parameters taken from data from other models.</p>
  
  <p>I initially try to find answer to "Where to store such classes?" here, and the answer was <code>apps/models</code> directory. That's ok, but I like to clearly separate these classes from ActiveRecord inherited classes in hierarchy, both as file and class.</p>
  
  <p>So, I created classes inside <code>Logic</code> module, like <code>Logic::EvaluationLogic</code> or <code>Logic::PhaseLogic</code>. I also wanted to have constants which passed between these logics. I prefer to place these constants into <code>Logic</code> module too. Thus, I implemented like this:</p>
  
  <pre><code># in logic/phase_logic.rb
  module Logic
    PHASE_INITIAL = 0
    PHASE_MIDDLE  = 1000
  
    class PhaseLogic
      def self.some_phase_control_code
      end
    end
  end
  
  # in logic/evaluation_logic.rb
  module Logic
    class EvaluationLogic
      def self.some_other_code
        Logic::PhaseLogic.self.some_phase_control_code(Logic::PHASE_INITIAL)
      end
    end
  end
  </code></pre>
  
  <p>Now, it work just fine with <code>rspec</code> (It passes tests I wrote without issues), but not with development server, since it can't find the <code>Logic::PHASE_INITIAL</code> constant.</p>
  
  <p>I suspect it's related to the mismatch of the autoloading scheme of Rails and what I wanted to do. I tried to tweak rails, but no luck, ended-up with eliminating <code>module Logic</code> wrap.</p>
  
  <p>Now the question I want to ask: How I can organize these classes with Rails?
  I'm using 3.2.1 at this moment.</p>
  
  <p><strong>Posted a follow-up question "<a href="https://stackoverflow.com/questions/9712468/how-i-can-organize-namespace-of-classes-in-app-modules-with-rails">How I can organize namespace of classes in app/modules with rails?</a>"</strong></p>