環境:cloud9(AWS)
初回のみ実行
①Railsをインストール
$ gem install rails -v 5.2.1
※バージョン指定しない場合は最新版が入る
②使用できるRailsのバージョンを確認
$ gem list rails
Rails5.2をCloud9(aws)で始める手順
①プロジェクトを作成
$ rails _5.2.1_ new projectname --database=mysql
※上記はmysqlを使用する例です。細かいオプションはドキュメントなどで要確認!
②プロジェクトに移動
$ cd ~/environment/projectname
③DBを作成
$ sudo service mysqld start
$ rails db:create
④サーバの起動
$ rails s -p 8080
※ポートは8080番を使用する
⑤「Yay! You’re on Rails!」の確認
Preview → Preview Running Application → Pop Out Into New Window
でRailsの画面が表示できれば成功です。
⑥Gitイニシャライズ
$ git init
$ git add .
$ git commit -m "init Rails Project"
あとは Model → Router → Controller → View と開発していくだけです!