12. Introduction to Ruby on Rails II
Activity 12.01: Create a Blog Application and Host It Live on a Cloud Platform
Solution
Part I – Create a blog application with the following features
- Create a new application and run the following command from Terminal:
$ rails new blog
The output should be as follows:
- Go into the
blog
directory and run the following scaffolding command from Terminal to generate MVC files and a folder structure forpost
:$ cd blog $ rails generate scaffold post title:string body:text
The output should be as follows:
- The
scaffold
command creates a lot of files and folder structures, essentially creating all the files required for CRUD operations. It has a model, a controller, migration, and views all generated in one go. Scaffolding is very powerful syntactic sugar, doing a lot of repetitive tasks quickly and saving time.
...