[RUBY] Preparing to create a Rails application

Creating an application

command


% rails _6.0.0_ new application -d mysql

-The version is specified in "6.0.0". -"Application" indicates the name of the application you want to create. -By adding the option "-d mysql" Use MYSQL as a data management tool.

Create database

config/database.yml


default: &default
  adapter: mysql2
  encoding: utf8
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: root
  password:
  socket: /tmp/mysql.sock

You can set the encoding like "utf8".

command


% rails db:create 

Create a database with the rails command.

Routing settings

config/route.rb


Rails.application.routes.draw do
  root to: "notes#index"
end

The index action of notes_controller will be called when the root path is accessed.

View and controller settings

config/application.rb


#abridgement
 config.load_defaults 6.0
#Omission
 config.generators do |g|
   g.stylesheets false
   g.javascripts false
   g.helper false
   g.test_framework false
 end

Before creating a controller with the rails g command, set not to generate unnecessary files.

commnad


% rails g controller notes index

If you specify the action name after the controller name when creating the controller, ・ Index action is created in notes controller ・ Index.html.erb file is created in the notes folder of views

Recommended Posts

Preparing to create a Rails application
[Introduction] Try to create a Ruby on Rails application
[rails] How to create a partial template
[Rails] Create an application
[Rails] rails new to create a database with PostgreSQL
[Rails] How to create a graph using lazy_high_charts
How to easily create a pull-down in Rails
[Rails] How to create a Twitter share button
How to create an application
How to create a method
[Rails] How to create a signed URL for CloudFront
Tutorial to create a blog with Rails for beginners Part 1
Introducing full calendar to Rails application
[Rails] I tried to create a mini app with FullCalendar
[Rails Tutorial Chapter 5] Create a layout
Create a new app in Rails
[Java] How to create a folder
I want to create a form to select the [Rails] category
A series of steps to create portfolio deliverables with Rails
Try to create a server-client app
Tutorial to create a blog with Rails for beginners Part 2
How to deploy a Rails application on AWS (article summary)
Tutorial to create a blog with Rails for beginners Part 0
[Rails 6] How to create a dynamic form input screen using cocoon
I tried to build a simple application using Dockder + Rails Scaffold
Install Rails in the development environment and create a new application
(Ruby on Rails6) Create a function to edit the posted content
I want to develop a web application!
[Rails6] Create a new app with Rails [Beginner]
Create a simple web application with Dropwizard
Introduce two-factor authentication to your Rails application
How to insert a video in Rails
[Rails withdrawal] Create a simple withdrawal function with rails
How to create a Maven repository for 2020
Steps to set a favicon in Rails
Preparing to introduce jQuery to Ruby on Rails
[Rails] Let's create a super simple Rails API
Rails Basics of creating a new application
[Swift5] How to create a splash screen
[Rails 5] Create a new app with Rails [Beginner]
How to create a query using variables in GraphQL [Using Ruby on Rails]
A note of someone who stumbled when trying to create a Rails project
[Docker] How to create a virtual environment for Rails and Nuxt.js apps
[Rails] How to create a table, add a column, and change the column type
Volume of trying to create a Java Web application on Windows Server 2016
Nuxt.js × Create an application in Rails API mode
Create authentication function in Rails application using devise
How to create a database for H2 Database anywhere
[Android] Inherit ImageView to create a new class
Connect to Aurora (MySQL) from a Java application
Add a tag function to Rails. Use acts-as-taggable-on
Try to create a bulletin board in Java
How to create pagination for a "kaminari" array
Create a Spring Boot application using IntelliJ IDEA
How to create a class that inherits class information
I tried to create a LINE clone app
Create a team chat with Rails Action Cable
How to create a theme in Liferay 7 / DXP
Try deploying Rails application to EC2-Part 2 (Server construction)-
[1st] How to create a Spring-MVC framework project
How to implement a like feature in Rails