Thursday, December 1, 2022

Building a Rails Blog App

 Rails comes with a number of scripts, called generators, designed to make a developer's life easier by creating everything they need to get started on a particular task. One of them is the new application generator, which provides you with the foundation of a Rails application so you don't have to write it yourself.


To use this generator, open a terminal, navigate to a folder where you have permission to create files, and run:


$ rails new blog

This will create a Rails app called Blog in the blog directory and install the gems whose dependencies are mentioned in the Gemfile when using bundle install.


You can see all the possible command line options that the Rails app generator accepts by running rails new --help.


Once you've created the blog app, navigate to its folder:


$ cd blog

The blog directory will contain several auto-generated files and folders that define the structure of the Rails application. Most of the work in this tutorial will take place in the app folder, but for now, let's go over the functions of each folder that Rails creates in the new default application:

Building a Rails Blog App

 Rails comes with a number of scripts, called generators, designed to make a developer's life easier by creating everything they need to...