Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
308
Help us understand the problem. What is going on with this article?
@narikei

最速!MacでRuby on Rails環境構築

More than 1 year has passed since last update.

homebrewをインストール

http://brew.sh/index_ja.html

Ruby編

rbenvをインストール

$ brew install rbenv
$ brew install ruby-build
$ rbenv version
2.2.3 (set by ******)

bash_profileに追記

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
$ source ~/.bash_profile

Rubyをインストール

$ rbenv install 2.6.1

rbenvのバージョンを切り替える

$ rbenv global 2.6.1
$ rbenv rehash
$ ruby -v
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin17]
$ gem -v
3.0.1

bundlerインストール

$ gem install bundler
$ bundle -v
Bundler version 2.0.1

MySQL編(SQLiteを使用する場合は不要)

MySQLをインストール

$ brew install mysql

MySQL起動

$ mysql.server start
Starting MySQL
SUCCESS! 

Rails編

てきとうなワークスペース

$ mkdir ~/workspace
$ cd ~/workspace

bundle init

$ bundle init
Writing new Gemfile to /Users/*****/workspace/Gemfile

できあがったGemfileのRailsのコメントアウトを外す

Gemfile
# A sample Gemfile
source "https://rubygems.org"

gem "rails"

Railsインストール

$ bundle install --path=vendor/bundle
Fetching gem metadata from https://rubygems.org/...........

Railsアプリケーション作成

$ bundle exec rails new .

聞かれたやつは全部 y

ライブラリインストール

$ bundle install --path=vendor/bundle
Fetching gem metadata from https://rubygems.org/...........

Railsアプリケーション起動

$ bundle exec rails s
PC-10214:workspace a13161$ bundle exec rails s
=> Booting WEBrick
=> Rails 4.2.5 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-12-13 02:24:12] INFO  WEBrick 1.3.1
[2015-12-13 02:24:12] INFO  ruby 2.2.3 (2015-08-18) [x86_64-darwin14]
[2015-12-13 02:24:12] INFO  WEBrick::HTTPServer#start: pid=55996 port=3000

おわり

http://localhost:3000/ へアクセスしてみましょう!

308
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
narikei
なんでも屋さん

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
308
Help us understand the problem. What is going on with this article?