title: Converting postgres query to rails active record
body: <blockquote>
    <p>postgres# <strong>select * from something;</strong></p>
    
    <p>id |   name   |             random_id             |<br>
    location                                                    |<br>
    created_at         |         updated_at         | type |<br>
    details                                                               </p>
    
    <p>----+----------+--------------------------------------+-------------------------------------------------------------------------------------------------------------------------+----------------------------+----------------------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</p>
    
    <p>15 | one   | 6abddaba-6b6e-4433-ae3b-698a16971704 | somehttp://one.tar.xz
    | 2017-05-02 06:55:36.146826 | 2017-05-02 06:55:48.154355 | openstack 
    | {"os": [{"release": "Fedora"}], "openstack_version": [{"buildhost":
    "openstack.com", "package_name": "nova", "package_version": 1.2,
    "openstack_version": 8}], "architecture": [{"kernel": "x86_64"}],
    "volume_drivers": [{"drivers": "ABCDriver"}], "network_drivers": [],
    "network_plugins": [], "shared_file_system_drivers": []}</p>
    
    <p>16 | two   | 9b13fb4c-2e20-4336-b486-473b50948ee1 | somehttp://two.tar.xz
    | 2017-05-02 06:55:52.219204 | 2017-05-02 06:56:03.212226 | openstack 
    | {"os": [{"release": "Fedora"}], "openstack_version": [{"buildhost":
    "openstack.com", "package_name": "nova", "package_version": 1.2,
    "openstack_version": 8}], "architecture": [{"kernel": "x86_64"}],
    "volume_drivers": [{"drivers": "XYZDriver"}], "network_drivers": [],
    "network_plugins": [], "shared_file_system_drivers": []}</p>
    
    <p>17 | three | 119eaf5f-166d-4ddd-a4db-d1f56bbf8779 |
    somehttp://three.tar.xz           | 2017-05-02 06:56:58.009536 |
    2017-05-02 06:57:06.538191 | openstack       | {"os": [{"release":
    "Fedora"}], "openstack_version": [{"buildhost": "openstack.com",
    "package_name": "nova", "package_version": 1.3, "openstack_version":
    9}], "architecture": [{"kernel": "x86_64"}], "volume_drivers": [],
    "network_drivers": [{"drivers": "linuxbridge"}], "network_plugins":
    [{"plugins": "ml2"}], "shared_file_system_drivers": []}</p>
    
    <p>19 | four | 139eaf5f-166d-4ddd-a4db-d1f56bbf8779 | somehttp://four.tar.xz
    | 2017-05-02 06:56:58.009536 | 2017-05-02 06:57:06.538191 | openstack 
    | {"os": [{"release": "Fedora"}], "openstack_version": [{"buildhost":
    "openstack.com", "package_name": "nova", "package_version": 1.3,
    "openstack_version": 9}], "architecture": [{"kernel": "x86_64"}],
    "volume_drivers": [], "network_drivers": [{"drivers": "bridge"}],
    "network_plugins": [{"plugins": "pqrst"}],
    "shared_file_system_drivers": []}</p>
  </blockquote>
  
  <p>I wanted to find entries in the table named "something" where "volume_drivers" could be "ABCDriver" or "XYZDriver" and network_drivers could be "linuxbridge".</p>
  
  <p>So, my result should consist of entries with id 15,16,17 as per above conditions.</p>
  
  <p>I tried doing the same using postgres shell and it worked, however, I am not able to map the same postgres query to ruby.</p>
  
  <pre><code>select * from something where details-&gt;'volume_drivers' IN ('[{"drivers": "ABCDriver"}]','[{"drivers": "XYZDriver"}]')                                                  OR details-&gt;'network_drivers' IN ('[{"drivers": "linuxbridge"}]');
  </code></pre>
  
  <p>I tried as below to at leat get the entry for ABCDriver and got nothing :(</p>
  
  <pre><code>Something.where('details-&gt;volume_drivers @&gt; ?', [{"drivers": "ABCDriver"}]);
  </code></pre>
  
  <p>Also, if someone has better suggestion to retrieve the same let me know.</p>