title: Constants in Padrino/Sinatra routes
body: <p>In Sinatra/Padrino where is a sensible place to add constants for use inside routes?</p>
  
  <p>I'm using Padrino to mount multiple apps so I want the constants available to all apps. (All apps inherit from a base class.)</p>
  
  <p>I've used <a href="http://www.sinatrarb.com/extensions.html#extending_the_request_context_with_" rel="nofollow">Sinatra.helpers</a> to add methods for use inside routes. </p>
  
  <p>I was hoping for a similar approach for constants.</p>
  
  <p><strong>Update</strong></p>
  
  <p>This appears to be a scoping issue, but I can't figure out what's wrong in this scenario.</p>
  
  <p>Here is a stripped down padrino app which demonstrates the problem:</p>
  
  <p><em>app.rb</em></p>
  
  <pre><code>class MyProject &lt; Padrino::Application
    register Padrino::Rendering
    register Padrino::Mailer
    register Padrino::Helpers
  
    MY_CONST = 123
  end
  </code></pre>
  
  <p><em>controllers.rb</em></p>
  
  <pre><code>MyProject.controller do
    get "/" do
      p self.class            # =&gt; MyProject
      p self.class.constants  # =&gt; [:DATA_ATTRIBUTES, ... &lt;snip&gt;..., :MY_CONST, ... &lt;snip&gt;... ]
      p MyProject::MY_CONST   # =&gt; 123
      p MY_CONST              # =&gt; NameError - uninitialized constant MY_CONST
    end
  end
  </code></pre>