Skip to content

Instantly share code, notes, and snippets.

@henriquegogo
Created February 23, 2011 20:34
Show Gist options
  • Save henriquegogo/841130 to your computer and use it in GitHub Desktop.
Save henriquegogo/841130 to your computer and use it in GitHub Desktop.
Exemplo de uma soma da quantidade de determinado registro num período
q=0;
r = Registro.find(:all, :conditions => ["created_at BETWEEN ? AND ?", Date.new(2010,6,1), Date.new(2010,7,1)])
r.each do |reg|
q = (q + reg.quantidade)
end
puts q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment