title: How to get an array of values from a conditional ActiveRecord query with associations?
body: <p>I'm looking to define a method on one of my objects that will return a just one column of data from all of its child objects so long as another column in the same record meets certain conditions.</p>
  
  <p>For instance if I have two objects</p>
  
  <pre><code>ParentObject
    has_many: child_objects
  
    #fields
    name (string)
  
  ChildObject
    belongs_to: parent_object
  
    #fields
    name (string)
    whitelisted_at (datetime)
  </code></pre>
  
  <p>I've read up that I can get a list of all child_object records for a parent_object based on a conditional specified using .where(). For instance in my controller I have code like so:</p>
  
  <pre><code>ParentObject.child_objects.where("whitelisted_at IS NOT NULL")
  </code></pre>
  
  <p>This gives me an active record associate like so:</p>
  
  <pre><code>#&lt;ActiveRecord::AssociationRelation [
  &lt;ChildObject id: 1, name:"Susan", whitelisted_at: "2015-02-18 12:07:37"&gt;,
  &lt;ChildObject id: 1, name:"Simon", whitelisted_at: "2015-02-18 12:07:37"&gt;, 
  &lt;ChildObject id: 1, name:"Sally", whitelisted_at: "2015-02-18 12:07:37"&gt;
  ]
  </code></pre>
  
  <p>I was looking how I would then filter through these to return an array of just names. Ideally i'd be able to run this all as a Model method so:</p>
  
  <pre><code>class ChainObject &lt; ActiveRecord::Base
  ...
    def whitelisted_names
      #... outputs [Susan, Simon, Sally]
    end
  end
  </code></pre>
  
  <p>What would be the most concise and rails-y way of doing this. I thought about doing a .where() then an .each() and having a block method but that seems really cumbersome and I'm sure I'm just missing some smart ActiveRecord or Association method that could pluck an array of values from multiple hashes. I'm pouring over the APIdock but I think the problem is I don't know how to describe what I'm trying to do!</p>