LoginSignup
1
1

More than 3 years have passed since last update.

ローカルでRails 6,Ruby 2.6.2のアプリ起動までの手順(mac)

Last updated at Posted at 2019-11-17

ローカル環境にrubyやmysqlがインストールしてあることが前提です。

$ mkdir sample-app
$ cd sample-app
$ bundle init
Gemfile
# frozen_string_literal: true
source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem "rails", "~>6"
bundle install --path vendor/bundle
bundle exec rails new . -B -d mysql --skip-turbolinks
  • -Bはbundle installを行わないようにする
  • -dはデータベースの指定(今回はmysql)

必要なgemをgemfileに追記

$ bundle install

このエラーが発生した場合

https___qiita-image-store.s3.ap-northeast-1.amazonaws.com_0_260982_7ed57a06-27e3-f631-9e80-f2479099a24b.jpeg

$ bundle config --local build.mysql2 "--with-cppflags=-I/usr/local/opt/openssl/include"
$ bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib"

それでもダメな場合

$ bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"
$ bundle install --path=vendor/bundle

正しいかはわからないが、これでひとまずいけた。

webpackerを導入する場合(vueバージョン)

$ rails webpacker:install
$ rails webpacker:install:vue
$ rails s -p 3000

localhost:3000でrails初期画面表示されれば完了!!
Screen Shot 2019-11-17 at 18.13.19.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1