Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Model Proliferation / Ability to set table name at runtime
- date | some_foreign_key | total
- activity_by_foo
- activity_by_bar
- activity_by_baz
- app/models/activity_by_foo.rb
- app/models/activity_by_bar.rb
- app/models/activity_by_baz.rb
- class Activity < ActiveRecord::Base
- def self.totals_for_period(start_date, end_date, id)
- select(:total).where(:start_date => start_date, :end_date => end_date, :some_foreign_key => id).sum(:total)
- end
- end
Add Comment
Please, Sign In to add comment