Quick Start with Rails on OS X
Install Ruby
OS X (10.4) comes with Ruby 1.8.2 already installed. For a quick start this is OK so let’s install Rails.
Install Rails
Since Rails comes as gem package, first we need to install RubyGems. Download the latest package from RubyForge and unzip it. Now go to the directory where you unpacked the package and run
When asked enter your password, and after install finish you can verify that everything went well by typing:
Output should look something like this, depending on version you installed
Now installing Rails is as simple as
To verify installation, type:
Install MySQL
You can skip this step if you don’t want to use database but since Rails is a framework for developing database-backed web applications, you’ll probably want to use one.
- Download the MySQL package for OS X for your platform
- Double-click the drive image to mount it
- Locate the MySQL installer (something like mysql-5.0.45-osx10.4-i686.pkg) and run it, authenticating as needed
- Double-click MySQLStartupItem.pkg
- Double-click MySQL.prefPane and install it
Once the install is complete, start the MySQL server using the control panel. ( System Preferences -> Other -> MySQL ) and check Automatically Start MySQL Server on Startup
Test your installation
To start a new project (application), go to the directory where you plan to keep your applications (i.e. ~/Apps) and execute following commands
This will generate Rails skeleton in ~/Apps/test_app, and start a WEBrick server on port 3000. Now open your browser and enter http://localhost:3000 in address bar. You should see a page with “Welcome aboard, You’re riding the Rails!” message.
We also need to tell Rails which database to use. To do this edit database.yml file (~/Apps/test_app/config/database.yml) to look like this
Naturally we also need to create a database
and table in that database
Execute scaffold command
Open http://localhost:3000/items and if you see something like this
you have everything needed to get started with Rails development so Enjoy!