the ruby teaching edition for macintosh

6
The Ruby Teaching Edition for Macintosh The Ruby Teaching edition for Macintosh is designed to be easily installed on a Macintosh system. The Ruby Teaching Edition works on Mac OS/X 10.5 - but Mac OS/X 10.5 already has Ruby and Rails installed - so you may want to simply use the versions of this software that comes with Mac OS/X 10.5. This installation also includes the SQLite3 Database Browser (http://sqlitebrowser.sourceforge.net/) to allow us to explore the contents of our SQLite3 databases that we will use with Rails. Installing Ruby Teaching Edition for Macintosh Download the latest version from: http://www-personal.umich.edu/~csev/teachrails/downloads/ Extract the file to your desktop - you should end up with a single directory called "rte- mac" - that directory should contain a file named "rsu.sh" and a subdirectory called ruby and hopefully this documentation. This rte-mac directory can be installed anywhere including your Desktop, Home Directory, a Shared File Server, USB drive or a USB stick. A USB stick will be somewhat slow - but may be your only choice in a shared environment. To install - simply move or copy the rte-mac to the desired location. Once you have it installed, continue with the instructions below. Using the Rails Training Environment for the Macintosh These instructions are to be followed anytime you want to start a new application or simply work on an existing application. We will do much of the control of our Rails environment through the Macintosh Terminal program. Start the terminal program under Applications -> Utilities -> Terminal.

Upload: sammy17

Post on 18-Dec-2014

215 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: The Ruby Teaching Edition for Macintosh

The Ruby Teaching Edition for Macintosh The Ruby Teaching edition for Macintosh is designed to be easily installed on a Macintosh system. The Ruby Teaching Edition works on Mac OS/X 10.5 - but Mac OS/X 10.5 already has Ruby and Rails installed - so you may want to simply use the versions of this software that comes with Mac OS/X 10.5. This installation also includes the SQLite3 Database Browser (http://sqlitebrowser.sourceforge.net/) to allow us to explore the contents of our SQLite3 databases that we will use with Rails.

Installing Ruby Teaching Edition for Macintosh Download the latest version from: http://www-personal.umich.edu/~csev/teachrails/downloads/ Extract the file to your desktop - you should end up with a single directory called "rte-mac" - that directory should contain a file named "rsu.sh" and a subdirectory called ruby and hopefully this documentation.

This rte-mac directory can be installed anywhere including your Desktop, Home Directory, a Shared File Server, USB drive or a USB stick. A USB stick will be somewhat slow - but may be your only choice in a shared environment. To install - simply move or copy the rte-mac to the desired location. Once you have it installed, continue with the instructions below.

Using the Rails Training Environment for the Macintosh These instructions are to be followed anytime you want to start a new application or simply work on an existing application. We will do much of the control of our Rails environment through the Macintosh Terminal program. Start the terminal program under Applications -> Utilities -> Terminal.

Page 2: The Ruby Teaching Edition for Macintosh

You might want to keep the Terminal program in your Dock by clicking on the terminal icon in the Dock and holding until a menu pops up.

Once the menu pops up select Keep in Dock and the terminal will be available in a single click. Once you are in the terminal, you use the cd command to get into the rte-mac directory. In this Example, the ret-mac directory is on the Desktop. Once you are in the rte-mac directory, type the commands as shown below. The output should be similar.

Once you have checked the ruby, rails, and gem commands. The only steps that are needed are to start the terminal, use cd to get into the rte-mac directory, and type the source rsu.sh command - from that point you can start developing your rails applications. You can develop your rails applications in any directory you like - in this example, we will simply put them in a directory called rails_apps in the rte-mac directory.

Page 3: The Ruby Teaching Edition for Macintosh

The rails command creates a new application as shown in the output below. The application is named "zork" in the example below and stored in a directory named "zork". The "-d sqlite3" indicates that we would like our Rails application to use the SQLite3 database. The rails command creates a large number of files - effectively writing our first application. $ cd Desktop/rte-mac/ $ source rsu.sh Setting up Ruby Environment $ cd rails_apps/ $ rails zork -d sqlite3 create create app/controllers create app/helpers create app/models [ …. Snip …. ] create log/production.log create log/development.log create log/test.log $

Once this is complete, we will go into the newly created "zork" directory and start the Ruby web server for our new application. create log/development.log create log/test.log $ cd zork $ pwd /Users/csev/Desktop/rte-mac/rails_apps/zork $ ruby script/server => Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment... ** Rails loaded. ** Loading any Rails specific GemPlugins ** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart). ** Rails signals registered. HUP => reload (without restart). It might not work well. ** Mongrel available at 0.0.0.0:3000 ** Use CTRL-C to stop.

Once this step is completed, you can access your new Rails application by opening a browser and pointing it to http://localhost:3000/

Page 4: The Ruby Teaching Edition for Macintosh

You can click on "About your application's environment" and check to make sure that it is using the sqlite3 database. All that is left is to shut down your web server. To do this we go back to the terminal. You should see some log information as your server was talking to the browser. You can press Control-C in the terminal to abort the web server.

Your test of the Ruby Training Edition for Macintosh is now complete. You can create and run Rails applications. Make sure to do the source rsu.sh command from the rte-mac directory each time you start a new window - or the rails and ruby command will not work properly.

Page 5: The Ruby Teaching Edition for Macintosh

Using RTE for the Macintosh on a USB Stick To install the Ruby Teaching Edition onto a USB Stick, simply copy the rte-mac directory onto the USB stick. You should make sure that the name of your USB stick has no spaces like the USB stick below:

To rename the USB stick gently single click on the words below the stick and it should allow you to change the volume label on the USB Stick. You can name it anything you like - just make sure there are no spaces. When you insert a USB stick into your Macintosh, the drive is mounted under the /Volumes directory using the disk name. So to navigate to the rte-mac directory o the USB stick you simple change to the proper directory as shown below: $ cd /Volumes/NONAME/rte-mac/ $ ls SQLite Database Browser 1.3.app rsu.sh rails_apps rte-mac.pdf readme.txt ruby $ source rsu.sh Setting up Ruby Environment $ rails --version Rails 1.2.6 All of the rest of the operations work the same as if the Ruby Training Edition were installed on your hard disk. Because running from a USB stick is slower - you might want to copy the ret-mac directory onto your desktop each time you work in a shared environment - it is about 60Mb - it takes about 30 seconds to copy. Make sure not to lose your work however when you move form computer to computer - you need to know where your Rails applications have been edited and copy them back to the USB stick before you leave the shared computer.

Copyright and Notes This material is Copyright 2007, 2008, Charles Severance - Creative Commons Attribution 2.5. You are welcome to use, reuse, adapt or remix this material in any way you feel useful. If you find mistakes or suggest improvements please contact the author.

Page 6: The Ruby Teaching Edition for Macintosh

If you are teaching Rails - I highly recommend this book: Build Your Own Ruby on Rails Web Applications by Patrick Lenz (http://www.sitepoint.com/books/rails1/). Please visit www.rubylearn.com to see if there is updated or additional materials available. I am anticipating a growing community of people who want to teach Ruby and Rails at the High School, and College level - I would like to see us developing and sharing materials as much as possible so we can focus on teaching as well as we can rather than always building materials from scratch individually. Dr. Charles Severance www.dr-chuck.com February 3, 2008