[RUBY] [Rails6] Create a new app with Rails [Beginner]

Overview

Hello, Qiita!! This article is about "The process of creating a new app with Rails 6". From Rails6, nice packages such as webpack and yarn will appear ~~ I don't understand ~~. I think there are many people who are addicted to building an environment (I am an example). I was able to build the environment with Docker, but since my understanding of Docker is too rough, I will post about the process in the local environment.

By the way, I'm a beginner who recently started making RoR apps. Please watch with warm eyes. : flushed:

I have also posted an article on Rails 5, so if you are interested, please see here.

Prerequisites

We will create an app in the above environment! : sunglasses:

Create a new app with Rails

On the terminal rbenv local 2.7.1 After executing rails _6.0.3_ new app_name -d mysql -B To execute.

What are you doing

For the usage and mechanism of rbenv, please refer to the following article because it is easy to understand. _ How to use and how rbenv works--Qiita _

Files in the app

If you do rails new on the terminal as above, many folders and files will be created. (The same content as Rails 5 is omitted.)

Files added from Rails 6

Babel.config.js

node_modules

yarn.lock

Yarn is a Node.js (JavaScript) package manager jointly developed by Facebook, Google, etc. ↑ I didn't know, it's amazing (no vocabulary): innocent:

Yarn itself is also a Node module package.

Originally, Node.js has a package manager called npm (Node Package Manager), but compared to npm, Yarn is

--Node module installation is very fast --There is a function that makes the same version no matter who makes it (version lock function) --Increased security --Command line output is simple and easy to read

It has the following features.

Rails has a Gem package manager called Bundler, but it's like its JavaScript version.

javascript/webpack

Before rails5, the javascript folder was placed under app / assets. In rails6, it is under app.

Webpack starts from the specified file, connects the files from there to the Imozuru formula relying on the import statement, and outputs the combined JavaScript file.

This bundling process is called a bundle. And the tool for bundling is called bundler.

The point seems to be that "basic functions are combined into one JavaScript file".

gem installation

The description of rails in Gemfile,

Gemfile


~
gem 'rails', '6.0.3'
~

Fix it with the version you want to use (ver.6.0.3 this time).

I skipped the gem installation with the -B command earlier, so on the terminal bundle install To execute.

Server startup

Let's actually start the server! On the terminal rails s To execute.

What are you doing

  • rails server _ can be _rails s _ but OK _: ok_hand:

If the following log is displayed on the terminal, the connection with the server is complete!

Use Ctrl-C to stop

Let's check it on your browser! Go to [localhost: 3000](http: // localhost: 3000)!

I was able to connect to the server! : metal:

At the end

Thank you for watching until the end. During my research, I learned that Ruby is a scripting language and Javascript is an interpreter language. As I explore the history of programming languages, I am deeply moved by the fact that various languages and frameworks are the accumulation of human wisdom. : thinking:

Also, in the future, I would like to write an article about how to add functions using various gems.

If you have any questions regarding this article, please let us know.

I've been feeling unpleasant with mask acne recently, so I think skin care is also important. : mask:

See you again! : walking_tone1:

Referenced website

Completely manage JS and CSS with webpack in Rails environment Understanding the basics of webpack and Babel Samurai blog

Recommended Posts

[Rails6] Create a new app with Rails [Beginner]
[Rails 5] Create a new app with Rails [Beginner]
Create a new app in Rails
[Rails] rails new to create a database with PostgreSQL
[Rails] Creating a new project with rails new
[Rails] I tried to create a mini app with FullCalendar
[Rails withdrawal] Create a simple withdrawal function with rails
Create a temporary class with new Object () {}
Create a simple search app with Spring Boot
Create a team chat with Rails Action Cable
rails new app is not created with app name
Create a LINEnews-style tech news summary app with Rails x LineBot! [Part 1]
[Rails] Launch a new project
Create an EC site with Rails 5 ⑨ ~ Create a cart function ~
[Beginner] Create a competitive game with basic Java knowledge
Create a Chat app with WebSocket (Tyrus) + libGDX + Kotlin
Create a playground with Xcode 12
[Beginner] I stumbled upon launching a project with Rails6
[Rails] New app creation --Notes--
How to get started with creating a Rails app
Tutorial to create a blog with Rails for beginners Part 1
Create a Hello World web app with Spring framework + Jetty
A series of steps to create portfolio deliverables with Rails
Tutorial to create a blog with Rails for beginners Part 2
Tutorial to create a blog with Rails for beginners Part 0
Create portfolio with rails + postgres sql
Preparing to create a Rails application
Create an app with Spring Boot 2
[Rails Tutorial Chapter 5] Create a layout
Create pagination function with Rails Kaminari
Creating a timer app with a muddy
Create an app with Spring Boot
Create command line app with maven
Track Rails app errors with Sentry
Try to create a server-client app
Create My Page with Rails devise
Create exceptions with a fluid interface
Create a Maven project with a command
The story of the first Rails app refactored with a self-made helper
[Rails] I made a simple calendar mini app with customized specifications.
Create a memo app with Tomcat + JSP + Servlet + MySQL using Eclipse
Create a JVM for app distribution with JDK9 modules and jlink
I got a warning message with the rails _6.0.3_ new hello_myapp command
Naming convention when creating a new controller or model with rails
Install Rails in the development environment and create a new application
Creating a new user with rails was angry with unknown attribute'password' for User.
Create a restaurant search app with IBM Watson + Gurunavi API (with source)
When a beginner makes a personal app with rails, the procedure to bring it to the starting point anyway.
Let's create an instance with .new yourself. .. ..
Create a jar file with the command
Create a simple web application with Dropwizard
Create Rails 6 + MySQL environment with Docker compose
Create a simple on-demand batch with Spring Batch
Create a GUI JSON Viewer with Ruby/GTK3
Try deploying a Rails app on EC2-Part 1-
Create a MySQL environment with Docker from 0-> 1
Create a simple bar chart with MPAndroidChart
Create a TODO app in Java 7 Create Header
Make a login function with Rails anyway
[Rails] Let's create a super simple Rails API
I made a rock-paper-scissors app with kotlin