Ruby on Rails Project Structure
A scalable and maintainable folder structure for Ruby on Rails applications
File Structure
- app
- controllers
- models
- views
- config
- routes.rb
- application.rb
- db
- migrate
- seeds.rb
- Gemfile
- README.md
Directory Structure Explanation
app/
The main application directory containing the core MVC components of the Rails application.
app/controllers/
Contains controller classes that handle HTTP requests and coordinate between models and views.
app/models/
Contains Active Record model classes that represent database tables and business logic.
app/views/
Contains view templates (ERB, HAML, etc.) for rendering HTML responses.
config/
Contains configuration files for the Rails application including routes and environment settings.
config/routes.rb
Defines the URL routing rules that map URLs to controller actions.
db/
Contains database-related files including migrations and seed data.
db/migrate/
Contains database migration files for version-controlled schema changes.
Gemfile
Specifies the Ruby gems (dependencies) required for the application.