Best place to put methods containing raw sql code

I’m porting a bunch of sql queries used to generate reports of various kinds. I have a report controller that has no model and will contain all the actions that display report results. Where should I stick my wrapper methods for these queries. I don’t like having them stuck right in the middle of my controller action code. Would the helper module for the report controller be a good place?

I’m porting a bunch of sql queries used to generate reports of various kinds. I have a report controller that has no model and will contain all the actions that display report results. Where should I stick my wrapper methods for these queries. I don’t like having them stuck right in the middle of my controller action code. Would the helper module for the report controller be a good place?

Why not place them in the most appropriate model? Helpers really should be in terms of helping you format your views per se, not business logic. You definitely dont want it in the controller if it is at all involved (and it should be if you are resorting to raw sql.

If there is no appropriate model then add one or more (not derived
from ActiveRecord) to hold the code.

Colin

A model does not necessarily have to have an associated table. It is still the place you want to put business logic. So, go ahead and create a model for this stuff, just don’t have it inherit from ActiveRecord::Base. It won’t inherit from anything.

Jamey