[Ruby on Rails] Setup Enviroment

作者: 木格袋子
发布时间:2015-07-13 11:28:14

There are three steps.

1. Install Ruby. 

It will be easier by using RVM. RVM is a ruby version manager.

1.1 Install RVM: https://rvm.io/rvm/install/

  Install RVM with ruby:

$ \curl -L https://get.rvm.io | bash -s stable --ruby  (By the way, curl is A command line tool for getting or sending files using URL syntax.)

1.2 Install ruby:

$ rvm install 1.9.3 (1.9.3 is the latest version of ruby)

1.3 Then do :  

$ rvm list

 You will see a list of ruby.


$ rvm --default use 1.9.3  (the version num depends on which version you installed)

error1 happens here : RVM is not a function, selecting rubies with 'rvm use ...' will not work.
  Solutions For error1: http://stackoverflow.com/questions/9336596/rvm-installation-not-working-rvm-is-not-a-function
error2 happens here : Gemset '' does not exist, 'rvm gemset create ' first, or append '--create'.
  Solutions For error2: rvm use 1.9.3 --create (it creates the gemset if not present, seems like the global gemset somehow got deleted)

1.4 do:  

$ ruby -v

 You will see expected ruby version. 

2. Install Gem: RubyGem is the standard Ruby Package Manager. 

 do: $ require 'rubygems'

 but you don't need to do this in Ruby 1.9 or higher, it's already included.

3. Install Rails


$ sudo gem install rails
errors happen here:

ERROR: Error installing rails:
ERROR: Failed to build gem native extension.


$ gem install rails


another thing: need to install "Common Line Tools" in XCode->Component

important thing: $ bundle install