title: Rails combine searching by enum and find_or_initialize_by methods
body: <p><em>this question is based on this one: <a href="https://stackoverflow.com/questions/30952981/rails-find-or-create-by-with-without-where">Rails find_or_create_by with/without where</a></em></p>
  
  <p>I've experienced some strange issue about <code>enum</code> &amp; <code>find_or_initialize_by</code> methods in rails.</p>
  
  <p>Let suppose I have the model <code>Task</code>.</p>
  
  <pre><code>class Task &lt; AR::Base
    enum status: { todo: 0, awaiting: 1, done: 2, another_one: 3, et.c. }
  </code></pre>
  
  <p>I want to find through <code>todo</code> and <code>awaiting</code> tasks, and if there is no exist, create a new one, but without a <code>todo</code> and <code>awaiting</code> value (status should be just nil). But, <code>ActiveRecord::Enum</code> strikes here!</p>
  
  <p>This is the normal code in most cases:</p>
  
  <pre><code>Task.where(status: [Task.statuses[:todo], Task.statuses[:awaiting]]).find_or_initialize_by(title: 'epic')
  </code></pre>
  
  <p>But because of <a href="https://github.com/rails/rails/blob/08576b94ad4f19dfc368619d7751e211d23dcad8/activerecord/lib/active_record/enum.rb#L105" rel="nofollow noreferrer">this</a> string I get annoying <code>'[0, 1]' is not a valid status</code> exception. How can I avoid this exception without superfluous code?</p>