Now that you've done Chapter 1 of the Rails Tutorial, you'll look back at what you did and what you failed. I'll take a closer look, so I'd be happy if you could take a look at the tutorial.
By the way, you can change the reading font to Mincho font or Gothic font. I made it very easy to read in Gothic style, so I think you should change it to your liking.
We'll also create a new app in Chapter 2, so it's okay if you can't deploy in this chapter.
The Rails tutorial introduces Progete related courses, I really feel that this should be done. The command line and Git courses are introduced in Chapter 1, I thought, "I can do it later," and after all, I made a mistake in the command, and the app was remade. We recommend that you take this course before you start.
Install Cloud9, a cloud IDE
$ printf "install: --no-document \nupdate: --no-document\n" >> ~/.gemrc
$ gem install rails -v 5.1.6 # Specify version with -v
$ cd ~ / environment # Change to the'environment' directory
$ rails _5.1.6_ new hello_app
1.3.1 Bundler Describe and install the default contents in the Gemfile by specifying the version.
$ cd hello_app/
$ bundle install
If it doesn't work, run bundle update
1.3.2 rails sever
$ cd ~ / environment / hello_app / Move to #hello_app directory
$ rails server # Start server
Please note that after starting the rails server, the inside of this terminal will be updated in real time. When you preview the screen, the Rails page is !! Yay!
1.3.3 Model-View-Controller
The story that each model view controller is involved.
model: application data, business rules, logic, functions view: Arbitrary information representation such as graphs and diagrams controller: Takes input and converts it into instructions for model and view -Quoted from Wikipedia
One question here. Rails has adopted this MVC architectural pattern. "Adopting this pattern" means that there are other patterns ...? I looked it up.
・ Forms and controls ・ Presentation model ・ Application model ・ MVVM ・ Model View Presenter (MVP)
Reference article https://www.atmarkit.co.jp/fdotnet/chushin/greatblogentry_10/greatblogentry_10_01.html
I couldn't understand the contents well, but I found out that there are other than MVC, of course! Programming is amazing when I think that it is free from the structure I will study this detailed content as well.
1.3.4 Hello,wold!
The following code is written to display Hello, world! Without passing through the view.
def hello
render html: "hello, world!"
end
I thought that the render method would be used like render ("folder name" / "file name")
, but you can also use it like this.
[Rails Guide 2.2 Use render](https://railsguides.jp/layouts_and_rendering.html#render%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%99%E3% 82% 8B) According to the Rails guide, you can output anything anymore.
Set the routing and display it in the browser.
From here, we will enable version control with Git.
$ git config --global user.name "Your Name"
$ git config --global user.email [email protected]
Please note that the name and email address here will be open to the public in the future.
In order to create a repository, write the following contents in the terminal
$ git init # Git initialization
$ git add -A # Add all files in the current directory
# Staged after file addition, waiting for commit
$ git status #Check current staging
$ git commit -m "Initialize repository" #Reflect with comment in repository
$ git log # View commit message history
What is a repository suddenly? It was like that, but it was very easy to understand when I read this. [[Remember with illustrations] Git and GitHub terminology for beginners] (https://zukulog098r.com/git/)
1.4.3 Gitbucket Update the source code to Gitbucket. The big advantage is that you can collaborate with other developers.
What is the "public key / encryption key" in the procedure? For the time being, I tried to make it as it was said, but I'm not sure, so I looked it up.
When exchanging data via the Internet, encryption is required to prevent information from being stolen. That's why public key cryptography was born. This key corresponds to each other. -Data encrypted with a public key cannot be restored with a private key (encryption key). -Data encrypted with a private key (encryption key) cannot be restored with a public key.
Anyone can see the public key. The side that sends the data acquires the information with the public key, encrypts it, and sends it. The recipient can restore and view the information encrypted with the private key (encryption key) that is not shown to anyone. This will prevent the information from being seen by a third party.
Because of this method, it is necessary to enter the public key for exchanging information.
Reference article https://railstutorial.jp/chapters/beginning?version=5.1#sec-bundler
$ git checkout -b modify-README #Create a topic branch for temporary use
$ git branch # Check all local branches
$ git commit -a -m "Improve the README file" # Commit all file changes at once
$ git checkout master #move to master branch
$ git merge modify-README Merge topic branch modify-README into #master branch
$ git push #push
Heroku says it uses a PostgreSQL database, What is PostgreSQL ...
PostgreSQL is an open source relational database. Full-fledged functions comparable to commercial databases and flexibility of use unique to open source are attractive. https://lets.postgresql.jp/map/intro
A relational database is a table type and seems to be a collection of associated data. Still difficult https://aws.amazon.com/jp/relational-database/
Add SQLite and install.
Also, install and deploy Heroku.
$ heroku --version Check if #Heroku is installed and version
$ source <(curl -sL https://cdn.learnenough.com/heroku_install) #Install Heroku on your cloud IDE
$ heroku login --interactive
$ heroku keys:add
$ heroku create #Create a new application on Heroku
Deploy to $ git push heroku master #Heroku
This is the end of Chapter 1.
I wanted to post a log, but the deployment didn't work.
When I think about it later, I think it's because I made a mistake in creating the branch and Heroku didn't quite understand that it needed to be accessed from the address generated by heroku create
.
It's been a long time, but thank you for reading this far. If you have any mistakes, please let me know.
Recommended Posts