[RUBY] Chewing Rails Tutorial [Chapter 1 From Zero to Deployment] First Half

1.1 Introduction

■REST "Create / Read / Update / Delete" often used in SQL is applied to "GET / POST / PUT / DELETE" respectively. It is necessary to write instructions one by one because state management such as sessions is not performed. Basically, it is described in "route.rb".

■ Command line Terminal. It comes standard with the cloud IDE.

1.2 Move immediately

■Cloud9 An integrated development environment that can be developed on the cloud provided by AWS. Super convenient because there is no need for troublesome environment settings

■gem Patch file? Additional elements? Something like. If you put it in a file called "Gemfile" and type bundle install into the terminal, it will be installed automatically.

1.3 First application

■rails new The first spell to write when building an application using Rails. It will automatically generate the necessary files.

■ Framework Rails is the framework. If you have an editor, you can program freely, but in the future it will be a mess of writing, so "let's arrange the writing to some extent". If you use Rails, you can do the same process with your own short expression, which takes dozens of lines when written in Ruby. There is no actual value yet.

■ Version for each game If the version is different, the behavior may be different, so it is better to fix the version for development. If spring 2.0.2 cannot be installed, type "bundle update spring" and then install again.

[Practice] It is written before the rails server was launched.

■ MVC model A concept that defines where and what files to put. It doesn't matter where you put anything, but since management will be troublesome later, I will write it with a certain degree of uniformity. I don't have a real feeling of where to write what.

■ render method A method that outputs the response. Use with both controller and view.

■ Method function. Use it by sandwiching it between def and end. When calling, write the defined method name.

■routes.rb Describe which page is returned for which request. Is it basically a controller?

■ 1.3.4 Rewrite to Hello, world! Rewrite the first "Yay! You're on Rails!" To Hello, world !. This time it's not a big deal so I probably won't mess with the view. Define a render method in the stove to display the HTML "hello, world!" Make root a hello method.

[Practice]

  1. OK if you change the text
  2. Since it is Windows, I do not know how to display it, so I skip it.

app/controllers/application_controller.rb


def goodbye
    render html: "goodbye, world!"
end

config/routes.rb


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

Like this.

Recommended Posts

Chewing Rails Tutorial [Chapter 1 From Zero to Deployment] First Half
Chewing Rails Tutorial [Chapter 1 From Zero to Deployment] Second Half
Rails Tutorial Chapter 1 From Zero to Deployment [Try]
Rails Tutorial 4th Edition: Chapter 1 From Zero to Deployment
Chewing Rails Tutorial [Chapter 2 Toy Application]
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 record and memorandum # 1 "From installation to hello_app deployment + error handling"
Chewing Rails Tutorial [Chapter 3 Creating Almost Static Pages]
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
OpenTracing Tutorial First Half
Rails Tutorial Memorandum (Chapter 3, 3.3.2)
[Rails Tutorial Chapter 4] Rails-flavored Ruby
[Rails tutorial] Cannot deploy to Heroku/Change from hello, world to hola, mundo
[Rails Struggle/Rails Tutorial] Summary of Rails Tutorial Chapter 2
[Rails Tutorial Chapter 5] Create a layout
rails tutorial chapter 10 summary (for self-learning)
Rails Tutorial (4th Edition) Memo Chapter 6
Tutorial 1 for building apps with Rails (First steps to Yay! You're on Rails!)
From pulling docker-image of rails to launching
Rails Tutorial 6th Edition Learning Summary Chapter 10
Rails Tutorial 6th Edition Learning Summary Chapter 4
[Rails] How to convert from erb to haml
Rails Tutorial 6th Edition Learning Summary Chapter 9
Rails Tutorial 6th Edition Learning Summary Chapter 6
Rails Tutorial 6th Edition Learning Summary Chapter 5
How to use MySQL in Rails tutorial
[Rails] Assigning variables from controller to JavaScript
Rails Tutorial 6th Edition Learning Summary Chapter 2
Rails Tutorial Chapter 0: Preliminary Basic Knowledge Learning 5
Rails Tutorial 6th Edition Learning Summary Chapter 3
Rails Tutorial 6th Edition Learning Summary Chapter 8
[Ruby on Rails] Rails tutorial Chapter 14 Summary of how to implement the status feed