开发者

how should I go about making many reports in the same ruby application

开发者 https://www.devze.com 2023-04-08 01:59 出处:网络
I am making an app that contains a lot of information the few users will want to have reports against.I might write 10 different reports against the 3 tables involved.Should I create multiple methods

I am making an app that contains a lot of information the few users will want to have reports against. I might write 10 different reports against the 3 tables involved. Should I create multiple methods on a report_controller to access each report?

for example I could have a report that is all_to_date or year_over_year_comparison.

I don't know if it would be better to write the reports as separate methods like /reports/report1 and reports/report2 etc or should I create a non database model for the reports an have many different pie开发者_Go百科ces in there?

Is there a better method?


Consider also using Presenters

  • http://www.subelsky.com/2008/01/presenter-classes-help-with-rails.html
    and
  • https://gist.github.com/1001089

Presenters allow you to extract the logic needed for complex views (especially views that require the use of more than one model) into a separate, easily testable class. This helps you write clean code and skinny controllers, among other benefits.


Take a look at the statistics gem, it should do what you need.

0

精彩评论

暂无评论...
验证码 换一张
取 消