Ruby on Rails5 Quick Learning Practice Guide 5.2 Compatible Chapter2

Let's take a look at Chaptrt2 Rails application

** Windows 10 environment construction ** In practice, HyperV Manager already has a virtual environment. ** Install Ubuntu 18.04.3 ** ** rbenv 1.1.2-30-gc879cb0 ** Install from GitHub using Git. ** Ruby 2.5.1 ** Install ** Rails ** installation ** Node.js ** installation

When using JavaScript, it has a function to compress JavaScript for efficient delivery, but it is installed because it requires a JavaScript runtime.

** Install and set up PostgreSQL ** Start PostgreSQL.  sudo service postgresql start

sudo su postgres -c'createuser -s {Ubuntu login user}' When I hit, I got the following error.

psql: FATAL: role “postgres” does not exist I entered the Ubuntu login user name without {} and it passed smoothly.

Use scaffold to automatically generate a "user management application" with the name scaffold_app with Rails commands.  rails new scaffold_app -d postgresql

The rails new command creates a Rails application template. Specify the name of the application as scaffold_app. The scaffold_app directory and related files are generated and logged. After this, bundle install will be executed automatically and the gem required to run Rails will be installed. Creating a database. Based on the definition in the file config / databese.yml.

bin/rails s db:create

Instead of "rails", "bin / rails" calls a script called rails in the bin directory directly under the application root directory. You can execute rails command in the environment where gem can be used according to Gemfile. ** Rails server start **  bin/rails s

rails uses Puma as the standard HTTP server.

** Check the server startup with a web browser ** Enter http: // localhost: 3000 / in the address bar.

** Create a template for user management functions ** Automatically generate scaffolds for "users".  bin/rails generate scaffold user name:string address:string age:integer

** Create a table for user management function in the database. ** **  bin/rails db:migrate

** Display user list screen **  http://localhost:3000/users Access the WEB browser by entering the above URL.

** Points I thought were important **

--The function "CRUD" required to manage users has been generated. ** "create" "read" "update" "delete" ** --Code path Rails application is composed of ** MVC (Model View Controller) **. The controller is called. The controller defines a method called "action" that describes the processing for the request (idnex action when the list screen is accessed).

Recommended Posts

Ruby on Rails5 Quick Learning Practice Guide 5.2 Compatible Chapter2
Ruby on Rails5 Quick Learning Practice Guide 5.2 Compatible Chapter3
Ruby on Rails 5 quick learning practice guide that can be used in the field Summary
Ruby on rails learning record -2020.10.03
Ruby on rails learning record -2020.10.04
Ruby on rails learning record -2020.10.05
Ruby on rails learning record -2020.10.09
Ruby on rails learning record-2020.10.07 ②
Ruby on rails learning record-2020.10.07 ①
Ruby on rails learning record -2020.10.06
Ruby on Rails6 Practical Guide cp13 ~ cp15 [Memo]
Ruby on Rails6 Practical Guide cp7 ~ cp9 [Memo]
Ruby on Rails6 Practical Guide cp4 ~ cp6 [Memo]
Ruby on Rails6 Practical Guide cp10 ~ cp12 [Memo]
Ruby on Rails6 Practical Guide cp16 ~ cp18 [Memo]
Ruby on Rails6 Practical Guide [Extensions] cp7 ~ cp9 [Memo]
Ruby on Rails6 Practical Guide [Extensions] cp10 ~ cp12 [Memo]
Ruby on Rails6 Practical Guide [Extensions] cp3 ~ cp6 [Memo]
Chapter 4 Rails Flavored Ruby
Rails Tutorial Chapter 3 Learning
Ruby on Rails Elementary
Ruby on Rails basics
Rails Tutorial Chapter 4 Learning
Ruby On Rails Association
Rails Tutorial Chapter 1 Learning
Rails Tutorial Chapter 2 Learning
[Ruby on Rails] Debug (binding.pry)
[Rails Tutorial Chapter 4] Rails-flavored Ruby
Cancel Ruby on Rails migration
Ruby on Rails validation summary
Ruby on Rails Basic Memorandum
[Ruby on Rails] Read try (: [],: key)
Ruby on Rails variable, constant summary
Installing Ruby + Rails on Ubuntu 18.04 (rbenv)
[Ruby on Rails] Introduced paging function
Basic knowledge of Ruby on Rails
Progate Ruby on Rails5 Looking Back
How to use Ruby on Rails
Ruby on Rails Japanese-English support i18n
(Ruby on Rails6) "Erase" posted content
[Ruby on Rails] CSV output function
Ruby on Rails 6.0 environment construction memo
[Ruby on Rails] Confirmation page creation
Ruby On Rails devise routing conflict
[Ruby on Rails] Comment function implementation
[Ruby on Rails] DM, chat function
[Ruby on Rails] Convenient helper method
[Ruby on Rails] Stop "looping until ..."
[Ruby on Rails] Introduction of initial data
Rails Tutorial 6th Edition Learning Summary Chapter 10
Rails Tutorial 6th Edition Learning Summary Chapter 7
[Rails] Addition of Ruby On Rails comment function
Rails Tutorial 6th Edition Learning Summary Chapter 4
[Ruby on Rails] View test with RSpec
[Ruby on Rails] Code check using Rubocop-airbnb
[Ruby on Rails] 1 model CRUD (Routing Main)
Ruby on Rails installation method [Mac edition]
Rails Tutorial 6th Edition Learning Summary Chapter 9
Rails Tutorial 6th Edition Learning Summary Chapter 6
[Ruby on Rails] model, controller terminal command
Ruby on Rails model creation / deletion command