Where to store long code block

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?