title: Rails CSV Download - Specify columns and get full URL
body: <p>I'm developing a marketplace app where sellers can list items to sell.</p>
  
  <p>I have a download CSV method which lets sellers download their listings.</p>
  
  <p>My method below downloads all columns. I have two questions:</p>
  
  <p>1) How do I specify columns, let's say I only want name, image, price.</p>
  
  <p>2) In the model, the image field just stores the image name such as item.jpg. But I want to export the URL where the image is stored. I'm using Paperclip to load images and Dropbox to save them. So each image has a dropbox url, which I want to export.</p>
  
  <p>my method in the model:</p>
  
  <pre><code>def self.to_csv(listings)
    CSV.generate do |csv|
      csv &lt;&lt; column_names
      listings.each do |listing|
      csv &lt;&lt; listing.attributes.values_at(*column_names)
     end
    end
  end
  </code></pre>