[RUBY] (Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 1]

Premise

・ Rails tutorial is the 4th edition ・ This study is the 3rd lap (2nd lap after Chapter 9) ・ The author is a beginner who has done all of Progate.

Basic policy

・ If you read it, you will not understand it. ・ Search and summarize terms that you do not understand (at the bottom of the article, glossary). ・ Dive into what you do not understand. ・ Work on all exercises. ・ Do not copy chords as much as possible.

Then go-go.

Overall flow

In Chapter 1, create the first "hello_app" -version control using Git-deploy to the production environment. In Chapter 2, scaffold is used to automatically generate code and create a "toy_app". From Chapter 3 to the last 14 chapters, create a twitter-like "sample_app" from scratch.

Although it is a tutorial, it is difficult without any prerequisite programming knowledge, so let's do the related course of Progate (charged).

[Progate course related to Rails tutorial] ·Chapter 1 Command line  Git ・ Chapter 4  Ruby ・ Chapter 5  HTML & CSS  Sass ・ Chapter 14  jQuery  JavaScript  SQL Rails basics  Ruby on Rails

(I realize I'm not doing the Sass course here. I'll do it before I start Chapter 5.)

[1.1.1 Prerequisite knowledge exercise]

  1. Which website has the Ruby gem used for Ruby on Rails? Tip: If you don't know, just google. → Result of google

  2. What is the latest version of Rails at the moment? → 6.0.3.2 (with 2020/6/17)

  3. How many times has Ruby on Rails been downloaded so far? Please check it out. → Cumulative download count: 239,792,613 (as of August 31, 2020)

[1.3.2 rails server exercise]

  1. What is the version of Ruby on your computer now compared to what is displayed on the default Rails page? You can easily check it by running ruby -v on the command line. .. → Run on Cloud9
$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
  1. In the same way, let's check the Rails version. Does the version you looked up match the version you installed in Listing 1.1? → It matches.
$ rails -v
Rails 5.1.6

[1.3.4 Hello, world! Exercise]

  1. Let's rewrite the hello action in Listing 1.7 so that "hola, mundo!" Is displayed instead of "hello, world!". → Rewrite the contents of the hello method of application_controller to "hola, mundo!"

  2. Rails also supports "non-ASCII characters". "¡Hola, mundo!" Contains the Spanish-specific upside-down exclamation mark "¡". To display the "¡" character on your Mac, hold down the Option key and press the 1 key. It may be faster to copy this character and paste it into your editor. → Above. Added

  3. Refer to the hello action in Listing 1.7 and add the second action goodbye. This action displays the text "goodbye, world!". Edit the routing in Listing 1.9 to change the route routing assignment from the hello action to the goodbye action. → Below

routes.rb


Rails.application.routes.draw do
  root 'application#goodbye'
end

application_controller.rb


class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
  
  def hello
    render html: "¡hola, mundo!"
  end
  
  def goodbye
    render html: "goodbye, world!"
  end
end

【1.4.3 Bitbucket】 The 4th edition of the tutorial uses Bitbucket as the report repository, but I feel that GitHub is more common, so I will challenge it. ・ ・ ・ ・ ・ ・

I was able to push it to GitHub without difficulty. (After that, I had a little trouble registering the public key while pushing) 隠し.png

[1.5.3. Deploy to Heroku (2) Exercise]

  1. Make the same changes as 1.3.4.1 so that "hola, mundo!" Can be displayed in the production application. → Returned the routing action to hello from the previous exercise, and corrected the render of the application controller to hola, mundo !. Commit again → Push to remote repository → Deploy to heroku.

  2. As with 1.3.4.1, change the routing to the route so that the result of the goodbye action is displayed. Also, when deploying, dare to omit the Git push master and make sure you can deploy with git push heroku. → Since I was doing the exercise (1.3.4) earlier, the result has been displayed. I changed it in Exercise 1, so I omitted it because it is annoying.

[1.5.4. Heroku command exercise]

  1. Execute the heroku help command to display a list of Heroku commands. Which command is the command to view the logs for the Heroku app? → heroku logs

  2. Use the commands found in the exercise above to check the recent log of the Heroku app. What was the most recent event? (Remembering the command to look at this log will help you find bugs in your production environment) → app [api]: Build succeeded?

Chapter 1 Summary

-For the time being, set the root and action of the route, Hello, world! -Version control with Git. The remote repository uses GitHub, which is not used in the 4th edition of the tutorial. -Deploy to Local → Remote → Heroku! -For the database, sqlite3 is used in the development environment and PostgreSQL is used in the production environment.

Go to Chapter 2! Click here for premise and author status for learning

A glossary that somehow captures the image

-Deploy Make the system such as a web application available from the outside. Reflect the system in the development environment → staging environment, staging environment → production environment.

・ Staging environment The stage of making a final check on the operation and display before releasing the system.

・ Commit Save the directory change history in the local repository (work environment: your PC).

・ Push Uploading committed data from a local repository to a remote repository (GitHub, Bitbucket, etc.).

・ Merge The meaning of "fusion" in Japanese. In other words, merge the changed topic branch with the master branch. Deleting a topic branch is optional.

Recommended Posts

(Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 11]
(Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 1]
(Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 14]
(Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 12]
(Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 5]
(Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 3]
(Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 4]
(Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 8]
(Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 6]
(Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 13]
(Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 9]
(Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 10]
(Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 7]
(Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 2]
(Giri) A local government employee in his twenties works on a Rails tutorial [Introduction]
[Ruby on Rails Tutorial] Error in the test in Chapter 3
[Rails Tutorial Chapter 5] Create a layout
[Rails Struggle/Rails Tutorial] What you learned in Rails Tutorial Chapter 6
[Rails Struggle/Rails Tutorial] What you learned in Rails Tutorial Chapter 3
(Ruby on Rails6) Creating data in a table
[Rails tutorial] A memorandum of "Chapter 11 Account Activation"
rails tutorial Chapter 6
rails tutorial Chapter 1
rails tutorial Chapter 7
rails tutorial Chapter 5
rails tutorial Chapter 10
rails tutorial Chapter 9
rails tutorial Chapter 8
[Rails Tutorial Chapter 2] What to do when you make a mistake in the column name
Rails Tutorial Chapter 5 Notes
Rails Tutorial Chapter 10 Notes
Rails Tutorial Chapter 3 Notes
Rails Tutorial Chapter 3 Learning
Rails Tutorial Memorandum (Chapter 3, 3.1)
Rails Tutorial Chapter 4 Notes
Rails Tutorial Chapter 4 Learning
Rails Tutorial Chapter 1 Learning
Rails Tutorial Chapter 2 Learning
Rails Tutorial Chapter 8 Notes
Rails Tutorial Memorandum (Chapter 3, 3.3.2)
Difficulties in building a Ruby on Rails environment (Windows 10) (SQLite3)
How to display a graph in Ruby on Rails (LazyHighChart)
Apply CSS to a specific View in Ruby on Rails