Forum: Ruby on Rails Where to store long code block

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Shauna (Guest)
on 2007-01-17 03:14
I've got a very long block of code within the create method in my
payments_controller.rb. This code is only called from that method in
that controller. But I would like to remove it from the controller
itself to a separate file somewhere, so the controller remains lean and
easy to read.

I've tried storing it as a separate module in \lib. I've also tried
storing it in the \helpers\payments_helper.rb module. The problem with
having it as a separate module is it doesn't share session, flash,
params, or any of the private methods already defined in
payments_controller.rb. There must be a simpler way than trying to pass
these objects back and forth.

I've started looking into "include" but so far I'm running into similar

Isn't there a simpler way to import a code block directly into a method?

This topic is locked and can not be replied to.