title: Access model-specific constants in a Rails view
body: <p>I'm running Rails 4.</p>
  
  <p>I have a model called <code>Challenge</code>, and in my database I'm storing the <code>status</code> of each challenge in terms of 0-4.</p>
  
  <p>But 0-4 isn't very semantic so I want to define a few variables (I'm assuming a constants) so that in any controller or view I can access the number by calling the constant:</p>
  
  <pre><code># Challenge.rb
  class Challenge &lt; ActiveRecord::Base
    SUGGESTED = 0
    APPROVED = 1
    OPEN = 2
    VOTING = 3
    CLOSED = 4
  end
  </code></pre>
  
  <p>I want to access these in my view:</p>
  
  <pre><code># challenge/_details.html.erb
  &lt;% if @challenge.status == CLOSED %&gt;
    Challenge is closed, broheim!
  &lt;% end %&gt;
  </code></pre>
  
  <p>But my view doesn't want to render.</p>
  
  <pre><code>uninitialized constant ActionView::CompiledTemplates::CLOSED
  </code></pre>
  
  <p>What's the best way to set my status variables so that they may be accessed everywhere I need them? (i.e, anywhere the <code>@challenge</code> variable is present)</p>