This README would normally document whatever steps are necessary to get the application up and running.
Things you may want to cover:
- Ruby version
Rails ver 5.2.0
ruby 2.5.1p57 (2018-03-29 revision 63029)
-
System dependencies
-
Configuration
fatモデル、fatコントローラにならないことを気をつける
基本的にControllerでの処理がfatになりやすいから、QueryやUsecaseを使う
-
Database creation
MySQL -> config/environment/development.log
socketの位置で環境変数を使う
-
Database initialization
-
How to run the test suite
-
Services (job queues, cache servers, search engines, etc.)
-
Deployment instructions
⭐️仮想環境を作る手順
-
以下のurlからVirtualBoxをインストール https://www.virtualbox.org/wiki/Download_Old_Builds_5_1 注意) 最新版はver5.2だけど、ver5.2は、まだrails使えないのでver5.1をインストール
-
VirtualBox内にcentOSインストール ターミナルで、
vagrant box add centos/7
を打つ。
途中で、選択が来るからVirtualbox
を選択。Successfuly
みたいなのが出たら、OK
-
mkdir vagrant
でvagrantディレクトリを作成。 -
cd vagrant
でvagrantディレクトリ内に入り、vagrant init centos/7
を実行(macOS上)。 -
4.が終了したらvagrantディレクトリ内に
ls
で、Vagrantfileができているか確認。
vagrant up
を実行。終了したら、
vagrant ssh
を実行し、vagrant内に入る。
このとき、
[vagrant@localhost@ ~]
になっていればOK
cd /vagrant
を実行し、pwd
コマンドでちゃんと/vagrant
になっていることを確認。
注) 必ず、異動先のコマンドで必ず/vagrant
にしてください!
-
Vagrantfileが存在するホストディレクトリ上(macOS側)と
ゲストディレクトリ上(centOS側)の
/vagrant
が共有してます。確認) 確認として、ターミナルを二つ開き、vagrantとmacとで分けてmacOS側で
touch test
でtestファイルを作ってみる。vagrant上で
ls
でtest
ファイルが存在すればOKできてなかったら、ゴウキにSlack投げて!
ここからは全てvagrantに入ってからの話。
- Gitインストール
yum -y install git
でGitをインストール
確認として
git --version
を実行!
もし入らなかったら、ググって解決してください!
- rbenvの導入
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
を順に実行。
rbenv --version
で入っているかを確認。
- ruby-buildの導入
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
- rubyの導入
sudo yum -y install openssl-devel gcc readline-devel libffi-devel mysql-devel gcc-c++
を実行。
rbenv install 2.5.0
を実行し、
rbenv global 2.5.0
でglobalに設定。
ruby -v
でver2.5.0が入っているかを確認。
- railsの導入
gem install multi_json -v '1.10.1'
rbenv exec gem install bundler
rbenv rehash
gem install rails
終了。
あとは、
git config
コマンドで、usernameとuser.emailを登録してくれれば、使えるようになるはず。
つまずいたら、Slack投げて!
bundle install
bundle exec rails db:migrate
※ 必要に応じては、
bundle exec rails db:migrate:reset