class Pageview < ApplicationRecord
  require 'csv'
  validates_presence_of :url, :visit_date

  def self.to_csv(options = {})
    CSV.generate(options) do |csv|
      csv << ["url", "visit counts", "date"]
      all.each do |pageview|
        csv << pageview.attributes.values_at("url", "visits", "visit_date")
      end
    end
end


end
