Organizing a MVC Project

Owen Mowery
2 min readApr 19, 2021

--

Organizing a project with many files is crucial to a smooth development journey. As you’re building your project out, you will realize how many files you end up using, which if not organized properly, will cause you to be spending an unnecessary amount of time searching through your file tree.

For this article, we will be setting up the proper file structure for a project that has a HTML, CSS frontend with a Ruby backend. First, you’re going to want to start by building out the models, views, and controllers. Start by creating a folder called “app”, this will hold the entirety of your MVC files. Create a folder called models, and inside that folder add the file “new_model.rb”. This will be your initial model for your project.

Next, we will be building out the structure for your views. Start by creating a folder called views, and inside that folder, add another folder which we will name “new_model”. The new_model folder will hold all .erb files that directly corresponds with your model, like “index.erb”.

For the last main we will build the controllers. Create a folder called “controllers”, and in that you can add a file called “application_controller.rb”. That will be your main controller to control how your application flows.

--

--

Owen Mowery
Owen Mowery

Written by Owen Mowery

Software Engineering Student

No responses yet