I have a Log model that belongs to User and Firm. For setting this I have this code in the logs_controller’s create action.
def create
@log = Log.new(params[:log])
@log.user = current_user
@log.firm = current_firm
@log.save
end
current_user and current_firm are helper methods from the application_helper.rb
While this works it makes the controller fat. How can I move this to the model?
I believe this sort of functionality belongs in a ‘worker’ class in
lib/. My action method might look likeAnd then I’d have a module in
lib/log_worker.rblikeThis is a simplified example; I typically namespace everything, so my method might actually be in
MyApp::Log::Manager.create(...)