Easiest way to split up a large controller file

Posted by timpone on Stack Overflow See other posts from Stack Overflow or by timpone
Published on 2012-09-23T21:29:30Z Indexed on 2012/09/23 21:37 UTC
Read the original article Hit count: 251

Filed under:

I have a rails controller file that is too large (~900 lines - api_controller). I'd like to just split it up like something like this:

api_controller.rb
api_controller_item_admin.rb
api_controller_web.rb

I don't want to split into multiple controllers. What would be the preferred way to do this? Could I just require the new parts at the end? like:

require './api_controller_item_admin'
require './api_controller_web'

© Stack Overflow or respective owner

Related posts about ruby-on-rails