title: Rails 5 get enum key via integer value
body: <p>I have a model that has the follow enum:</p>
  
  <pre><code>class User &lt; ApplicationRecord
      enum user_type: [:api_user, :web_user]
  end
  </code></pre>
  
  <p>When this gets saved into the database, it saves it with the integer value, as expected. I then have a function that accepts the enum like this (in a controller):</p>
  
  <pre><code>do_something_useful(type: User.user_types[:web_user], user: user)
  
  def do_something_useful(options)
      some_enum_value = options[:type]
      user = options[:user]
  
      # Not a practical example.  Just an example to demonstrate the issue.
  
      # Should return Hello, User! You are a web_user type.
      # But returns, Hello, User! You are a 1 type.
      'Hello, #{user.name}! You are a #{some_enum_value} type.'
  end
  </code></pre>
  
  <p>The problem I'm encountering is that the options[:type] is passing the integer value.  I'd like to get the key value of User.user_type by the integer.  Is this possible?</p>
  
  <p>Thanks again.</p>