Skip to content

Instantly share code, notes, and snippets.

@milushov
Created May 10, 2013 14:58
Show Gist options
  • Save milushov/5554942 to your computer and use it in GitHub Desktop.
Save milushov/5554942 to your computer and use it in GitHub Desktop.
def week_stat model
table = model.name.tableize
from = Time.now - 7.days
query = "
select created_at, count(*)
from #{table}
where created_at > '#{from}'
group by created_at
"
wstat = ActiveRecord::Base.connection.select query
binding.pry
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment