Keeping controllers clean

176 views Asked by At

Let's say I have some logic that's being performed on the params hash passed into a controller action. I'd like to encapsulate the logic in some methods to keep the code understandable and to keep the controller clean. I could put the methods in the Order model as class-level methods. However, these methods are not really core to the domain responsibility of the Order model. My question is where's the best place to house these type of methods in Rails?

OrdersController < ApplicationController
   def update
       # check some conditions here on the params hash...
       # need some methods to do it...
       # where's a good place for these methods other than model or controller?
   end 
end
2

There are 2 answers

0
Jordan On BEST ANSWER

Make them private instance methods of the controller.

0
rmk On

How about putting these in ApplicationHelper?