rails tutorial vscode
vscodeでrails tutorialをやる
今後も使うことがあるかもしれないので残しておく
VS codeの初期設定とRuby on Railsの環境設定 環境構築
こちらの記事を参考にさせていただきました
railsプロジェクトの作成
$ rails new app --database=mysql $ cd app $ bundle install
bundle install
を実行したところ
An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: mysql2
こんなエラーが出た、とりあえずエラーログに記載されているコマンドを実行して見たがだめ
原因までは理解しなかったが、とりあえず解決することはできた
$ bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib" $ bundle install
このコマンドでエラーが解消される、その後
$ rails db:create $ rails s
rails s
を実行するとwebpackerがないというようなエラーが出る
ログ上に記述されているrails webpacker:install
を実行すると無事に成功しもう一度rails s
で「You're on Rails」の画面を開くことができた