Download Ruby On Rails For Mac
This tutorial will detail steps you need to follow to install Ruby on Rails on Mac. The main preparation that you must have is your terminal. If you already open your terminal, let’s move on. 1) Install Xcode You need to install this first because Xcode provides powerful tools to handle extra commands for installing Ruby. To install Xcode, open your appstore, search “xcode” and click install.
It will take some time to install Xcode due to its big size. 2) Install RVM (Ruby Version Manager) By default, your mac already has Ruby installed, try to execute ruby -v in terminal and you will see the version. Unfortunately, it will get you in trouble in future if you need more than one Ruby version. Let’s say you have project A that requires Ruby 2.0 and another project B that requires older Ruby 1.9. How can you have two different Ruby version installed in same machine and switch between them?
The answer is RVM. Installing RVM is piece of cake, open your terminal and type/copy paste: gpg -keyserver hkp://keys.gnupg.net -recv-keys 409B6B1796C2113804BB82D39DC0E3 curl -sSL bash -s stable These command will also modified some of your system files. You can read the output of installer to check which files were modified. 2) Restart Terminal Restart terminal and load RVM with this command: source /.rvm/scripts/rvm To check if rvm is correctly installed.
Try to type: rvm -v You should see rvm version installed. 3) Install Ruby To check list of all known rubies that you can install, you can type: rvm list known Let’s say you want to install Ruby 2.1, you must type rvm install ruby-version like following: rvm install 2.1 To use your newly installed Ruby, type: rvm use 2.1 Later, you can easily switch to another ruby version using this command. To check if your ruby correctly installed, type: ruby -v You should see 2.1 If you restart your terminal, and type ruby -v, you will see that your old Ruby is still being referenced. You can make your installed ruby as default for your system by type: rvm use 2.1 -default Try to restart your terminal and type ruby -v again. 4) Install Rails Installing rails is quite easy, type: gem install rails It will take some time, so you may need a coffee To check if your rails is correctly installed, type: gem list It will display installed gems.
You can see Rails there. Conclusion This tutorial guides you how to install Ruby on Rails on mac using command line. We install Ruby using RVM. My experience tells me that different ruby’s project will probably need different ruby version. Using RVM is necessary because it can help you to switch between ruby version easily.
After Ruby is installed, installing Rails is easy. Happy Ruby-ing!
Installing Ruby on Rails for Mac Installing Ruby on Rails for Mac This page provides the simplest instructions for installing Ruby on Rails 3.0.x on a Mac computer. It has been most recently tested on a Mac Mini running Lion (10.7). The instructions will probably work provided that the Mac already has Ruby 1.8.7 installed. If it doesn't, additional suggestions are provided below. Install XCode is a free download.
You may have an XCode DVD that came with the computer, but it will be better to download XCode to ensure a recent version (recommended versions are 4.1 or later for Lion, 3.2 or later for Snow Leopard and 3.1 or later for Leopard). If you download XCode from the Apple Developer site, you will probably need to. XCode takes a while to download, even on a reasonably fast network. Be prepared to do some waiting. XCode has an install package that you can double-click to get started.
Download Ruby On Rails
When I ran XCode for Lion, the installation appeared to stall at the very end. Apparently this is a common problem.
However, XCode seems to be installed anyway. Restarting the computer or force-quitting the installer gets you on your way.
Terminal Window and Testing for Ruby You will need to use the Terminal Window for entering typed commands. The Terminal application is located in the Utilities subfolder inside the Applications folder. You can double-click the Terminal application to get it started, but you will probably want to drag it to the control panel at the bottom of your display for easy future access. With the Terminal open, test for Ruby by typing this command, followed by the Return key: ruby -v If 1.8.7 appears in the response, these instructions should work for you.
Setting up the Gem installer Our text (Agile Web Dev with Rails) suggests the following steps for getting the gem installer set up (p. 5): sudo gem update -system sudo gem uninstall rubygems-update I'm not quite sure why the second step is needed, but I did it for my installation and it worked fine. Note that sudo is required before these commands. These commands install software in folders with restricted access. The sudo command tells the Mac OS that you have those privileges and you must authenticate with your Mac password. Installing Rails We will be using Rails version 3.0.9 in this class and that is what you should install.
Here are the commands: sudo gem install rails -version 3.0.9 sudo gem install sqlite3 Testing To really test if your installation is working, you should test it with a database. The easiest and most gratifying way is to create a scaffolded Rails application.
Here's how to do that. First, go to a directory where you will want to create your application directory. For example, if you want your application directory (folder) to be in the documents directory (folder), enter the following command in the Terminal: cd Documents The command cd stands for change directory. You are now in the Documents directory. The command ls will list all of the files in the current directory. You can verify the current directory with the pwd command.
Now create your rails application, giving it a name (e.g. Travel): rails new travel I suggest giving your rails app name a thematic name like travel, music, dining, sports, etc, which should match the goals of your application. Then change directory to your new applicaton: cd travel Create a scaffold: rails generate scaffold Airport city:string code:string Create the database table: rake db:migrate Start the server: rails server You can now verify if you application is working in a browser at where the last word should be the plural version of your scaffold (model) name. It is possible that your Mac doesn't have the most recent version of ruby. In that case, the installation process is a bit more complicated. You will need to install ruby yourself.
The simplest approach is to use. With MacPorts installed, you can then upgrade sqlite3 and install Rails and Gems: sudo port upgrade sqlite3 sudo port install ruby sudo port install rb-rubygems I haven't recently tested these commands, but they are the same as suggested in the Agile Web Dev book (p. After these commands run, you can then proceed to install Rails as documented above.