1 Install rails gem
#For rails6
gem install rails -v 6.0.1
#rails5.In case of 2
gem install rails -v 5.2.1
2 MySQL settings (MySQL itself is installed by default in Cloud9)
#If you do not install this, you will get an error when installing mysql2 gem.
$ sudo apt-get install libmysqld-dev
3 Rails new
$ rails new appname -d mysql
4 Create a MySQL Account
$ sudo mysql -u root #Login as root user
$ mysql> create user 'username' identified by 'password'; #User created
$ mysql> grant all on *.* to 'username'; #ALL authorization
#To confirm the created user, use the following command
$ mysql> select User,Host from mysql.user;
5 Edit config / database.yml
default: &default
adapter: mysql2
encoding: unicode
pool: 5
#Below, 3 lines added
username: <username> #Same as the set MySQL Account
password: <password> #Same as the set MySQL Account
host: localhost
development:
<<: *default
database: appname_development #The appname should be the appname for rails new.
test:
<<: *default
database: appname_test #The appname should be the appname for rails new.
6 Create database with rails db: create & install webpacker
$ cd appname
$ rails db:create
#Not required for rails5
$ source <(curl -sL https://cdn.learnenough.com/yarn_install)
$ yarn install --check-files
$ rails webpacker:install
#config/enviroments/development.rb
config.hosts.clear
Recommended Posts