LoginSignup
0
0

More than 5 years have passed since last update.

とりあえずMacにRuby on Rails環境構築

Last updated at Posted at 2018-11-25

はじめに

色々初心者
Railsチュートリアルやる前にとりあえず動かすための記録

環境

macOS Mojave 10.14.1

Homebrewインストール

Homebrew macOS 用パッケージマネージャー

rbenvインストール

$ brew install rbenv
$ echo 'export PATH="~/.rbenv/shims"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile

Rubyインストール

$ rbenv install 2.5.3
$ rbenv global 2.5.3

Bundlerインストール

$ gem install bundler

MySQLインストール&起動

$ brew install mysql
$ mysql.server start

作業ディレクトリ作成

$ mkdir ~/workspace
$ cd ~/workspace

Gemfile作成

$ bundle init

Gemfileのgem "rails"をアンコメント

Gemfile
# frozen_string_literal: true

source "https://rubygems.org"

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

gem "rails"

Railsインストール

$ bundle install --path=vendor/bundle

Railsアプリ作成

$ bundle exec rails new hello_app
$ cd hello_app

Railsアプリ起動

$ bundle exec rails s

http://localhost:3000/ にアクセスして確認

ここまで4時間くらいかかった(bash_profileで何かミスってPATHが消えた)

その他

bundle exec省略

やっておくと楽?

$ echo 'export RUBYGEMS_GEMDEPS=-' >> ~/.bash_profile
$ source ~/.bash_profile

参考

最速!MacでRuby on Rails環境構築
Ruby初学者のRuby On Rails 環境構築【Mac】
いちいちbundle execしたくない 決定版

0
0
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
0
0