class Account < ActiveRecord::Base
  has_many :invoices
  def invoice
    invoices.where(:payment => :consume, :state => :enabled).where("started_at < '#{Time.now}'").where("expires_at > '#{Time.now}'").first
  end
end
用于返回当前账户下有效账单的函数:)这个写法看上去好不爽~~~~~