LoginSignup
0
3

More than 5 years have passed since last update.

MacOSX Sierra でRubyonRailsの開発環境を構築する

Posted at

もともとvagrant上で開発していましたが、ポート関連とかWebSocketとか諸々問題が発生することが多く、快適に開発できないのでMac自体に環境を構築することにしました。

Homebrewのインストール

本体のインストール

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bash_profile
$ source ~/.bash_profile

インストール確認

$ brew doctor
Your system is ready to brew.

最新パッケージへの更新

$ brew update
Already up-to-date.

Rubyのインストール

rbenvのインストール

$ brew install ruby-build
$ brew install rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile

rubyのインストール

2.3系の最新を入れることにしました。

$ rbenv install -l
$ rbenv install 2.3.4
$ rbenv global 2.3.4
$ rbenv version
2.3.4 (set by /Users/ryo/.rbenv/version)
$ ruby -v
ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-darwin16]

Railsのインストール

$ gem install rails
$ gem install bundler
$ rbenv rehash
$ source ~/.bash_profile
$ rails -v
Rails 5.0.2

railsサンプルアプリを動かしてみる。
各プロジェクト用ディレクトリとして私はホームディレクトリ配下にwebappディレクトリを作成しています。

$ mkdir webapp
$ cd webapp
$ rails new sample
$ cd sample/
$ rails g scaffold Name name:string
$ rake db:migrate
$ rails server

http://localhost:3000/names
にアクセス

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