0
我有一個模型如下獲取有序散列
class Quote < ActiveRecord::Base
named_scope :from_affiliate_id, Proc.new { |id|
{ :select => "COUNT(*) as count_all, date(created_at) as date_created_at",
:conditions => {:affiliate_id => id},
:group => "date(created_at)",
}
}
named_scope :in_dates, Proc.new {|from,to|{ :conditions => ["date(created_at) >= ? and date(created_at) <= ?",from,to]}}
belongs_to :affiliate
def self.create_quote(value = '')
return if value.nil?
quote = self.new(:affiliate_id => value)
quote.save
end
end
當我做Quote.from_affiliate_id(1),我得到以下結果
[#<Quote >, #<Quote >, #<Quote >, #<Quote >]
我想獲得一個有序的Hash代替。哪一個應該有一個日期作爲一個關鍵並計入價值。請幫助我。在預期
非常感謝shingara,真的幫助 – usmanali 2010-11-22 13:53:19