Bir modelim varSipariş edilen bir hash elde etmek
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
Ben Quote.from_affiliate_id (1) yaptığımda, aşağıdaki sonucu elde ederim
[#<Quote >, #<Quote >, #<Quote >, #<Quote >]
Sipariş edilen bir Hash almak istiyorum. Anahtar olarak bir tarih olmalı ve değer olarak sayılmalıdır. Lütfen bana yardım et. Bir beklenti
teşekkür
sayesinde gerçekten çok shingara, yardım etti – usmanali