title: How can I query Rails ActiveRecord data stored in arrays
body: <p>I have a rails model call MentorData and it has an attribute called <code>os_usage</code>. The oses are stored in an array like so <code>['apple',  'linux']</code>.</p>
  
  <p>To recap:</p>
  
  <pre><code>$ MentorData.first.os_usage
  =&gt; ['apple',  'linux']
  </code></pre>
  
  <p>I am looking to be able to query the data for all MentorData that includes the os_usage of <code>apple</code>, but when I search <code>MentorData.where(os_usage: 'apple')</code> I only get the mentors who can only use apple and not apple and linux. I need to search in some way that checks if apple is included in the array. </p>
  
  <p>I have also tried the following.</p>
  
  <pre><code>MentorData.where('os_usage like ?', 'apple’)
  MentorData.where('os_usage contains ?', 'apple’)
  MentorData.where('os_usage contains @&gt;ARRAY[?]', 'apple')
  </code></pre>
  
  <p>Is it possible to query data in ActiveRecord by attributes that have an array or items?</p>
  
  <p>The database is on Postgres if that helps in providing a more raw search query.</p>