I’m at the point where I have a lot of view files for each controller in
my app. I’d like to be able to add another level or two of directories
in my view folders just for organizational purposes. What’s the best
way to do this?
I could split the actions into multiple controllers, but then I’d want
some sort of organization to group controllers then… Once a project
reaches a certain size, actions tend to organize hierarchically at least
my project has. Just wondering if there’s an easy way to organize all
those files hierarchically since their logical group is hierarchical
Thanks for the help so far. Here’s a more concrete example of what I’m
talking about. I have an app used for warehousing and fulfillment.
Some of the controller domains are:
Receiving
Locating Items
Shipping Out Items
Finance Related Stuff
Shipment Tracking
Within just the Receiving controller there are dozens of view files
because it’s become larger and larger over the years. You need to be
able to receive a shipment, then receiving individual items in a
shipment, track exception cases, edit previous check in data, etc. I’d
really like a way to organize some of those files such that I have
/receiving/shipment_check_in/…, /receiving/exceptions/…,
/receiving/item_check_in/…
All my controllers are getting to this size or are already there. I was
just wondering if there was an easy way to refractor and organize
projects of these size.
Thanks for the help so far. Here’s a more concrete example of what I’m
talking about. I have an app used for warehousing and fulfillment.
Some of the controller domains are:
Receiving
Locating Items
Shipping Out Items
Finance Related Stuff
Shipment Tracking
Within just the Receiving controller there are dozens of view files
because it’s become larger and larger over the years. You need to be
able to receive a shipment, then receiving individual items in a
shipment, track exception cases, edit previous check in data, etc. I’d
really like a way to organize some of those files such that I have
/receiving/shipment_check_in/…, /receiving/exceptions/…,
/receiving/item_check_in/…
All my controllers are getting to this size or are already there. I was
just wondering if there was an easy way to refractor and organize
projects of these size.
Your controllers are far too big and general. Receiving should not be
one controller. You’d probably want a ShipmentsController, an
ExceptionCasesController, and so on.
You could probably benefit from redesigning your controllers to follow a
RESTful pattern. You needn’t adhere slavishly to it, but using REST as
a guideline will give you a better idea of what controllers are normally
expected to do.
Since you don’t have many details posted, I’ll suggest a generic
solution that worked for me:
Use partials. You can populate them based on sub-categories within
your actions or groups or whatever your ‘parent’ classification is.
You can implement whatever heirarchy you like - each level would have
a partial, that would then render the child levels as needed. Render
using conditionals or a loop, and you can turn three partials into a
three-level-deep, nested heirarchy.
Hope that helps. Post details for better assistance.
SR
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.