title: Failed to populate table in haml with database values - Ruby on Rails
body: <p>I have a site where customers can purchase tickets for an event and created a <code>Reporter::EventTickets</code> class to generate a hash for the relevant information I need. <code>Reporter::EventTickets</code> is called in a Reports controller, and ultimately I want to view this on an admin report page.</p>
  
  <p>I cannot get the information to display on my table in my haml view file! 
  I've tried everything I can think and am at a complete loss for what to do.   </p>
  
  <p>Information is being saved to the database (PostgreSQL) successfully and the EventTickets class is transforming data properly (passing RSpec tests). </p>
  
  <p>Code:</p>
  
  <pre><code>class Reporter::EventTickets
    include Virtus.model
  
    def events
      products.map do |product|
        line_items = LineItem.includes(:order)
          .where("orders.completed_at IS NOT NULL")
          .where(purchasable_type: "Product", purchasable_id: product.id)
          .references(:order)
  
        ticket_purchases = line_items.map do |line_item|
          order = line_item.order
  
          [order.bill_address_full_name, order.email, line_item.quantity]
        end
        total = ticket_purchases.reduce(0) { |sum, purchase| sum + purchase.last }
  
        {
          date: product.event_date,
          name: product.name,
          total: total,
          purchases: ticket_purchases.sort
        }
      end
    end
  
    private
  
    def products
      Ticket.where("event_date &gt;= ?", week_ago_in_time_zone).order("event_date ASC")
    end
  
    def week_ago_in_time_zone
      (Time.current - 7.days).to_date
    end
  
  end
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>def event_tickets
      @reporter = Reporter::EventTickets.new
      @csv_link = admin_reports_event_tickets_path(format: :csv)
      respond_with @reporter
  end
  </code></pre>
  
  <p>Models:</p>
  
  <pre><code>class Order &lt; ActiveRecord::Base
    has_many :line_items, dependent: :destroy
  </code></pre>
  
  <pre><code>class LineItem &lt; ActiveRecord::Base
    belongs_to :order, touch: true
    belongs_to :purchasable, polymorphic: true
  </code></pre>
  
  <pre><code>class Product &lt; ActiveRecord::Base
    include Purchasable
    has_many :line_items, as: :purchasable
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>= render partial: "admin/shared/header", locals: {title: "Event Ticket Purchases"}
  .container-fluid.padded
    = render partial: "admin/shared/notifications"
    .row-fluid.hidden-print
      = link_to "Download CSV", @csv_link, class: "btn btn-blue"
    .row-fluid
      - @reporter.events.each do |event|
        %h3
          = event[:date].strftime("%_m/%e")
          = event[:name]
        .box
          %table.table.table-normal
            %thead
              %tr
                %td Name
                %td Email
                %td Tickets
            %tbody
              - event[:purchases].each do |purchase|
                %tr
                  - purchase.each do |column|
                    %td= column
              %tr
                %td{:colspan =&gt; "2"}
                  %b TOTAL
                %td
                  %b= event[:total]
  
  </code></pre>
  
  <p>There are no errors from Rails and the page loads with the title and button. The table just does not populate.</p>