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

Overview

"Hello everyone, good evening"

(... I wanted to say it once)

I'm a beginner who recently started making RoR apps. Since this is Qiita's first post, I would like to post about the insanely rudimentary "process of creating a new app with Rails"! : writing_hand:

Prerequisites

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

Create a new app with Rails

On the terminal rbenv local 2.5.1 rails _5.2.3_ new app_name --database=mysql --skip-bundle To execute.

What are you doing

  • If ʻapp_name _ is _.`_, it will be created on the current directory _
  • --database = mysql _ is OK with -d mysql _: ok_hand:
  • --skip-bundle _ can be -B but _: ok_hand:

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 contents should look like this:

app

It contains the application's controllers, models, views, helpers, mailers, channels, jobs, and assets.

bin

Contains script files such as Rails scripts for launching, updating, and deploying applications.

config

The application's configuration files (routing, database, etc.) are located here.

db

It contains the current database schema and database migration files.

lib

Contains extension modules used by the application.

log

Contains the application log files.

public

The files under this folder can be viewed directly from the outside (Internet). Place static files and compiled assets here.

storage

Contains Active Storage files used by the Disk service.

test

Place test related files such as Unit tests and fixtures here.

tmp

Temporary files such as cache and pid are placed.

vendor

All code written by third parties is placed here. For a normal Rails application, put the external gem file here.

.gitignore

Specify a file (or pattern) that is not registered in Git in this file.

.ruby-version

The default Ruby version is specified in this file.

config.ru

A Rack configuration file for Rack-based servers that you need to launch your application.

Gemfile

Describes the gem dependencies required by your Rails application. This file is used by the Bundler gem.

package.json

You can specify the npm dependencies required by your Rails application in this file. This file is used by Yarn.

Rakefile

This file describes the tasks that you can perform from the command line. The task definition here is defined for the Rails-wide components.

If you want to define your own Rake task, writing it directly in Rakefile is too powerful, so try to add a file for Rake under the lib / tasks folder as much as possible.

README.md

Fill in the manual here to give an overview of the application. It is necessary to fill in this file with the application setting method etc. so that anyone can build the application by reading this.

gem installation

Gem in Ruby has the following two roles.

  1. Package
  2. Package management tool

By using the package, development can proceed efficiently, so it seems that it is often used in the actual field. Since the package can be installed easily, even beginners of Ruby on Rails can quickly equip it with full-scale application functions. : relaxed:

Gemfile with the function you want to use in the app

Gemfile


gem 'gem name'

It is described as. (Here, I will omit the specific types of gems.)

Also, the description of rails in the Gemfile,

Gemfile


~
gem 'rails', '5.2.3'
~

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

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

What are you doing

Server startup

Let's actually start the server! On the terminal rails server 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!

=> Booting Puma
=> Rails 5.2.3 application starting in development 
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.6 (ruby 2.5.1-p57), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop

Let's check it on your browser! Go to localhost: 3000 (localhost: 3000).

Yay!

You have successfully connected to the server! : sunglasses:

At the end

Thank you for watching until the end. In the future, I'd like to write articles about how to register users with devise and how to build a RoR environment on Docker (it is undecided when).

Also, if you have any questions regarding this article, please let us know. As an engineer, I want to start running as soon as possible. : walking_tone 1:: walking_tone 1:: walking_tone 1: Well then!

Referenced website

Rails Guide CodeCampus

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
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 a Vue3 environment with Docker!
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.
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
[Rails] Let's create a super simple Rails API
I made a rock-paper-scissors app with kotlin
Rails Basics of creating a new application
[rails] How to create a partial template