Skip to content

Instantly share code, notes, and snippets.

@LRDesign
Created March 24, 2010 20:49
Show Gist options
  • Save LRDesign/342778 to your computer and use it in GitHub Desktop.
Save LRDesign/342778 to your computer and use it in GitHub Desktop.

Revisions

  1. LRDesign created this gist Mar 24, 2010.
    2 changes: 2 additions & 0 deletions Result of query ...
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    # doesn't include any joins from the :include => eager load call!
    Payment Load (0.3ms) SELECT * FROM `payments` WHERE (`payments`.`paid_at` BETWEEN '2010-03-01 00:00:00' AND '2010-03-31 23:59:59') ORDER BY paid_at ASC
    19 changes: 19 additions & 0 deletions admin/payments_controller.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    class Admin::PaymentsController < Admin::AdminController

    def index
    if params[:date]
    @show_only = DateTime.new(params[:date]['show_only(1i)'].to_i, params[:date]['show_only(2i)'].to_i)
    conditions = { :paid_at => (@show_only.beginning_of_month..@show_only.end_of_month) }
    joins = :cart
    order = 'paid_at ASC'
    @payments = Payment.find(:all, :conditions => conditions, :order => order, :include => joins).paginate
    else
    @payments = Payment.paginate :order => 'paid_at DESC', :page => params[:page]
    end
    end

    def show
    end

    end

    6 changes: 6 additions & 0 deletions cart.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    class Cart < ActiveRecord::Base
    belongs_to :person
    has_many :event_registrations, :dependent => :destroy
    has_many :membership_applications, :dependent => :destroy
    has_one :payment, :dependent => :destroy
    end
    3 changes: 3 additions & 0 deletions payment.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    class Payment < ActiveRecord::Base
    belongs_to :cart
    end