Hey guys,
Where is the best place to put methods called in your controller? I ask
because my controller file is getting bulky with code that doesnt need
to be called directly.
I was wondering if I could put it in the application.rb or if there is
some way to put it in the helper?
On 7/30/06, Eric G. [email protected] wrote:
–
Posted via http://www.ruby-forum.com/.
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
The code that is not called directly may be better placed into a module
in
your lib directory. The actions that get called on the controller as an
action should certainly go into the controller in 99.99% of situations.
You can put code into the application helper, but this is generally for
views.
IMHO this is simply put as:
If a method is data integrity related, try and put it in the model.
If a method only exists to support the flow of the controller logic, put
it
in a controller.
If a method is there to assist with displaying content, stick it in a
view.
With any/all of these, modules are always available.
It’s a bit hard to know what advice to give with such a small ammount of
information.
Hope that helps