Preparation for developing with Rails

Introduction

When developing with Rails, I will write the preparation to the point where I start writing code. We will proceed with VirtualBox and Vagrant already installed. If you haven't installed VirtualBox and Vagrant yet, try searching on Google.

table of contents

  1. Vagrant initialization
  2. Start Vagrant
  3. Connection to virtual environment
  4. Move to the shared folder of the virtual environment
  5. Start developing with Ruby on Rails
  6. At the end of work
  7. At the end

1. Vagrant initialization

First, go to your desktop in the terminal.

$ cd Desktop

Then create a folder named "work" and move to that folder.

$ mkdir work
$ cd work

After that, create a folder name "vagrant" in the folder "work" and move to that folder.

$ mkdir vagrant
$ cd vagrant

Create a Vagrantfile in this folder called "vagrant".

$ vagrant init

This completes Vagrant's initial setup. Check in the terminal that it looks like the following.

Username: vagrant username$

2. Start Vagrant

Next, start Vagrant. From this point onward, I think it will be a task that is performed every time development is carried out.

Starting Vagrant is easy. Type the following command.

$ vagrant up

The very first startup takes a tremendous amount of time. You may eat rice and take a bath. Maybe you can watch a movie. If you've done that much, you'll probably be done when you realize it: baby:

When the first boot is complete To the bottom, With the words Your now on Rails! A picture of a train: something like: steam_locomotive: appears.

This completes Vagrant startup.

3. Connection to virtual environment

Make an "SSH connection" to securely communicate with your PC in the virtual environment. Type the following command.

$ vagrant ssh

When connected correctly

[[email protected] ~]$

It will be displayed like this.

The connection to the virtual environment is now complete.

4. Move to the shared folder of the virtual environment

Shared folders in your virtual environment are located in / home / vagrant / work. So move to that shared folder.

[[email protected] ~]$ cd /home/vagrant/work

If the following is displayed, it means that you have moved.

[[email protected] work]$

5. Start developing with Ruby on Rails

Use the rails new command when creating a new application in Ruby on Rails. To create an application called "sample", type as follows.

$ rails new sample

If this command is executed correctly, the sample folder will be created in the shared folder.

Select "Open" or "Open" from the file menu with VScode etc. Select "Desktop"-> "work"-> "vagrant"-> "sample", Open the sample folder.

Once you have done this, type the following command to move to the sample directory you created earlier.

[[email protected] work]$ cd sample

If the part that was "work" becomes "sample", it means that you can move it.

[[email protected] sample]$

Now you are ready to start writing the code. At this point, you can start writing code.

Thank you for your hard work.

6. At the end of work

You may want to log out of the virtual environment and shut down the virtual environment every time you finish your work and before closing your computer.

With this command, you can log out from where you are "SSH connected".

[[email protected] work]$ exit

Logout is complete when the following is displayed.

Username: vagrant username$

Next is the shutdown of the virtual environment. You can shut it down by typing the following command.

$ vagrant halt

If you want to shut down the virtual environment and start it again, Start over with $ vagrant up.

7. At the end

Thank you for watching until the end. Actually, I wrote it for myself in the future when I forgot.

I would be grateful if you could let me know if there are any mistakes.

I will continue to write articles for myself in the future and for those who happen to find my article and see it.

Recommended Posts

Preparation for developing with Rails
Challenge the settings for developing with vue.js on Rails 6
Using Material Design for Bootstrap with Rails 5.2
[Rails] Procedure for linking databases with Ruby On Rails
[Rails] Building an environment for developing web applications
Rails deploy with Docker
[Rails 6] RuntimeError with $ rails s
Handle devise with Rails
[Rails] Learning with Rails tutorial
[Rails] Test with RSpec
[Rails] Development with MySQL
Supports multilingualization with Rails!
Double polymorphic with Rails
Stable development environment construction manual for "Rails6" with "Docker-compose"
Using PAY.JP API with Rails ~ Implementation Preparation ~ (payjp.js v2)
[Java] Environment construction procedure for developing struts 1.3 with Eclipse
Tutorial to create a blog with Rails for beginners Part 1
[Rails] Upload videos with Rails (ActiveStorage)
Try using view_component with rails
docker-compose command list (for Rails)
[Vue Rails] "Hello Vue!" Displayed with Vue + Rails
Japaneseize using i18n with Rails
API creation with Rails + GraphQL
(For beginners) [Rails] Install Devise
Run Rails whenever with docker
[Docker] Rails 5.2 environment construction with docker
Use multiple databases with Rails 6.0
[Rails] Specify format with link_to
Login function implementation with rails
Tutorial to create a blog with Rails for beginners Part 2
Tutorial to create a blog with Rails for beginners Part 0
[Docker] Use whenever with Docker + Rails
Building an environment for creating apps with Rails and Vue
For beginners! Automatic deployment with Rails6 + CircleCI + Capistrano + AWS (EC2)
[Java] Sample project for developing web applications with Spring Boot
Summary of steps for developing in Docker container with VS Code
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
Creating a new user with rails was angry with unknown attribute'password' for User.
"Rails 6 x MySQL 8" Docker environment construction procedure for sharing with teams
Rails + MySQL environment construction with Docker
Create portfolio with rails + postgres sql
[Rails] Push transmission with LINE Bot
Summary of rails validation (for myself)
Java_HOME setting for paths with spaces
[Rails] Make pagination compatible with Ajax
Environment construction with Docker for beginners
[Rails] DB design for EC site
Implemented mail sending function with rails
[Rails] Creating a new project with rails new
rails tutorial chapter 10 summary (for self-learning)
Minimal Rails with reduced file generation
Build environment with vue.js + rails + docker
Eliminate Rails FatModel with value object
Recognize Rails projects with Intellij idea
[Grover] Generate PDF with Rails [2020 version]
Enable OpenCV with java8. (For myself)
Build Rails environment with Docker Compose
[Rails] Initial data creation with seed
Learn AWS for free with LocalStack
Track Rails app errors with Sentry
Using Java with AWS Lambda-Eclipse Preparation