-
Notifications
You must be signed in to change notification settings - Fork 0
Set up Rails
Ryuji EGUCHI edited this page Jun 7, 2023
·
8 revisions
NOTE:
This document is for Mac.
If you use windows, use Windows Subsystem for Linux. See below.
(English) https://gorails.com/setup/windows/10
(Japanese) https://qiita.com/Aruneko/items/c79810b0b015bebf30bb
You can skip this if you have already set up Rails development environment on your local.
-
Install ruby-build and rbenv
$ brew install ruby-build $ brew install rbenv
-
Add the following settings to
.zshenv
(.bash_profile
for bash) in accordance with the install log.export PATH="$HOME/.rbenv/bin:$PATH" if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
-
Check the available versions of ruby
$ rbenv install -l
-
Install readline
$ RUBY_CONFIGURE_OPTS="--with-readline-dir=$(brew --prefix readline)"
The Japanese characters are garbled without this. (これがないと、rails console で日本語入力が化ける)
-
Install ruby (The version can be changed. It should be 2.5.1 as of 2018/4/11)
$ MAKE_OPTS="-j 4" rbenv install 2.5.1
MAKE_OPTS="-j 4" is for parallel compile.
-
Set the ruby version
$ rbenv global 2.5.1 $ rbenv versions system * 2.5.1
-
Install bundler
$ gem install bundler
-
Install rails
$ gem install rails
$ app_name='<your_app_name>'
$ database='mysql'
# or
$ database='postgresql'
## postgresql is more common with Rails.
$ rails_version='7.0.5'
## The version depends on the project.
$ rails _${rails_version}_ new ${app_name} --database=${database} --skip-bundle --skip-test
## --skip-test is for not installing minitest because we use rspec.
## --skip-action-cable and --skip-turbolinks are likely options.
$ cd ${app_name}
$ git init
$ git commit --allow-empty -m "initial commit"
## This is not mandatory.
$ git add .
$ git commit -m 'add rails'
$ bundle config set --local path 'vendor/bundle'
$ bundle install
- You might think of using UUID for ID.