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.
On 1/19/07, athem
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> 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!
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---