title: Postgres JSON data type Rails query
body: <p>I am using Postgres' json data type but want to do a query/ordering with data that is nested within the json.</p>
  
  <p>I want to order or query with .where on the json data type. For example, I want to query for users that have a follower count > 500 or I want to order by follower or following count.</p>
  
  <p>Thanks! </p>
  
  <p>Example:</p>
  
  <pre><code>model User
  
  data: {
       "photos"=&gt;[
         {"type"=&gt;"facebook", "type_id"=&gt;"facebook", "type_name"=&gt;"Facebook", "url"=&gt;"facebook.com"}
        ], 
       "social_profiles"=&gt;[
           {"type"=&gt;"vimeo", "type_id"=&gt;"vimeo", "type_name"=&gt;"Vimeo", "url"=&gt;"http://vimeo.com/", "username"=&gt;"v", "id"=&gt;"1"},
           {"bio"=&gt;"I am not a person, but a series of plants", "followers"=&gt;1500, "following"=&gt;240, "type"=&gt;"twitter", "type_id"=&gt;"twitter", "type_name"=&gt;"Twitter", "url"=&gt;"http://www.twitter.com/", "username"=&gt;"123", "id"=&gt;"123"}
       ]
  }
  </code></pre>