I have a set of methods that use AR objects to query the database and use the results, in combination with the application of some simple business rules (e.g., if-else statements + return values), to compute values for display in a view. My question is, generally, where is the appropriate place to put such code (not in the view!)? (1) The view-specific helper (2) The model (3) The controller Thanks!
on 2007-01-19 20:27
on 2007-01-19 21:27
If it is very view specific, you can put them in a view helper. If these methods are needed in almost all the controllers then you can put them in a superclass. Otherwise put them in a helper module and mix it in the controllers that requires it. Think about your application requirements and use your judgement. Instead of speculating, you could refactor it later. I would also separate the business rule logic code from the data manipulation code. This will allow code reuse.