Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby On Rails Package By Feature

Is there any way to package your code by feature in rails? I would like to structure my project so that each feature has its controllers, jobs, mailers, layouts and helpers in its own folder. e.g.

app
----user
--------jobs
--------controllers
--------mailers
--------layouts
--------helpers

----company
--------jobs
--------controllers
--------mailers
--------layouts
--------helpers

where user and company are seperate features.

like image 595
strizzwald Avatar asked Oct 27 '25 10:10

strizzwald


2 Answers

I've done this in my app and its pretty easy.

You create your file structure the way you want it and then you just put config.autoload_paths += %W(#{config.root}/app/user/jobs) or whatever other subdirectory you want into your application.rb folder.

People might say this is not the rails way but I feel your pain when your project gets really big and hard to navigate.

like image 178
stevo999999 Avatar answered Oct 29 '25 00:10

stevo999999


Checkout Trailblazer gem. It is an extension on the basic MVC pattern.

like image 25
ogirginc Avatar answered Oct 28 '25 23:10

ogirginc