Ruby on Rails - convention over configuration in ruby on rails - ruby on rails tutorial - rails guides - rails tutorial - ruby rails
- In Rails, we find ourself looking at controllers, views, and models for our database.
- To reduce the need for heavy configuration, Rails implements rules to ease up working with the application.
- We may define our own rules but for the beginning (and for later on) it's a good idea to stick to conventions that Rails offers.
- These conventions will speed up development, keep your code concise and readable, and allow you an easy navigation inside your application.
- Conventions also lower the barriers to entry for beginners. There are so many conventions in Rails that a beginner doesn’t even need to know about, but can just benefit from in ignorance. It’s possible to create great applications without knowing why everything is the way it is.
- These conventions will speed up development, keep our code concise and readable, and allow we an easy navigation inside our application.
- Conventions also lower the barriers to entry for beginners. There are so many conventions in Rails that a beginner doesn’t even need to know about, but can just benefit from in ignorance. It’s possible to create great applications without knowing why everything is the way it is.
- We have a database table called orders with the primary key id, the matching model is called order and the controller that handles all the logic is named orders_controller. The view is split in different actions: if the controller has a new and edit action, there is also a new and edit view.
Example
- To create an app we simply run rails new app_name. This will generate roughly 70 files and folders that comprise the infrastructure and foundation for our Rails app.
It includes:
- Folders to hold your models (database layer), controllers, and views
- Folders to hold unit tests for your application
- Folders to hold your web assets like Javascript and CSS files
- Default files for HTTP 400 responses (i.e. file not found)
- Many others