Created
March 24, 2010 20:49
-
-
Save LRDesign/342778 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Payment < ActiveRecord::Base | |
belongs_to :cart | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment