Convention over Configuration

Convention over Configuration is a core Ruby on Rails principle that reduces the need for manual setup by following predefined conventions. It allows developers to focus on building features instead of spending time on configuration details.

Table of Contents

What is Convention over Configuration in Ruby on Rails?

Convention over Configuration (CoC) is a software design philosophy that guides how Ruby on Rails applications are structured and built. It means Rails assumes sensible defaults for how things should work, so developers don’t have to write extensive configuration code.

For instance, Rails knows that a model named User corresponds to a database table called users and that a controller named UsersController will look for its views in the app/views/users directory, without you having to explicitly tell it.

In short, Rails makes intelligent assumptions about your project’s structure, helping you write less code while maintaining clarity and consistency.

Why is Convention over Configuration Useful?

Without conventions, every Rails project would require custom configuration for files, routes, and naming, making setup time-consuming and error-prone. CoC solves this by:

  • Reducing repetitive setup and boilerplate code

  • Making new projects faster to start

  • Enforcing consistent project structure and naming conventions

  • Helping teams collaborate easily by following predictable patterns

  • Lowering the learning curve for developers joining existing projects

By following conventions, developers can spend more time on business logic instead of wiring up the basics.

How Convention over Configuration Works

Rails applies conventions throughout the framework:

  • Naming conventions: Models are singular (e.g., Article), tables are plural (articles), and controllers are plural (ArticlesController).

  • File structure: Rails automatically maps files to their roles (models in app/models, views in app/views, controllers in app/controllers).

  • Automatic routing: Rails infers routes from controller and action names.

  • Default behaviors: If a view or partial exists with a matching name, Rails renders it without explicit instructions.

Developers can override these conventions when needed, but in most cases, the defaults work.

Where to Use Convention over Configuration

  • In any Rails project to accelerate development

  • When building scalable web apps with large teams

  • For maintaining consistent codebases across projects

  • When creating prototypes or MVPs quickly

  • In enterprise applications that benefit from predictable structure

In Summary

Convention over Configuration is what makes Ruby on Rails development fast, structured, and efficient. By embracing well-defined conventions, developers write less configuration code, maintain cleaner projects, and achieve faster development cycles, without sacrificing flexibility.