在 mac 上安裝 Rails

在安裝 rails 之前,你需要安裝 ruby

Mac 已根據你的 macOS 最近安裝了 ruby?根據你希望開發的 ruby 版本,安裝 Ruby 的最佳方法是使用 RVM 。在終端中,鍵入以下步驟中列出的命令:

  1. 安裝 rvm

     placeholderCopycurl -sSL https://get.rvm.io | bash -s stable --ruby
  2. 對於 Rails 3,安裝的最佳版本是 ruby 1.9.3

     placeholderCopyrvm install 1.9.3
    ruby -v #=> 1.9.3
  3. 設定你的 Ruby 版本

     placeholderCopyrvm use 1.9.3 --default
  4. 安裝 Rails (這個 rails 版本需要 ruby-version> = 1.9.3)

     placeholderCopygem install rails -v 4.2.7.1
    rails -v #=> 4.2.7.1
  5. 安裝 rails app

     placeholderCopyrails new my_first_app #(this will install the app for you.)
    cd my_first_app
    rails s #(run the server)
  6. 開啟瀏覽器,在 URL 中輸入以下內容。

     placeholderCopyhttp://localhost:3000

    將顯示訊息“歡迎使用 rails”或類似資訊。