Ruby On Rails

From Helpme

Revision as of 20:05, 19 February 2013; view current revision
←Older revision | Newer revision→
Jump to: navigation, search



Ruby on Rails is available on the Linux workstations in the Design Center.

  • Ruby Version: 1.9.x
  • Rails Version: 3.2.x

Setting up your environment

To put Ruby and Rails into your environment, type:

$ setup ruby

Now you should be able to run commands like:

$ ruby --version
ruby 1.9.3p385 (2013-02-06) [x86_64-linux]
$ rails --version
Rails 3.2.12

Creating a new Rails app

To create a new rails application, simply run:

$ rails new ~/rails/app_name

This will create the directory "~/rails/app_name" that contains your rails application, along with several default files and directories underneath it that you can modify to further build your application.

Running your Rails app

$ hostname
$ cd ~/rails/app_name
$ rails server -p $(
=> Booting WEBrick
=> Rails 3.2.12 application starting in development on
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2013-02-19 11:38:10] INFO  WEBrick 1.3.1
[2013-02-19 11:38:10] INFO  ruby 1.9.3 (2013-02-06) [x86_64-linux]
[2013-02-19 11:38:10] INFO  WEBrick::HTTPServer#start: pid=6507 port=3002

Note the call to "" above. This is critical. If you do not do this, rails will attempt to start your application on the default port of 3000. If someone else on the system is already running their application, you will be unable to start yours unless you specify a free port. The "" script finds a free port automatically, but only if you call it as described above.

Viewing your Rails app

To view your Rails application in a browser, you would then point your browser to:


From the example above, we have started our rails app on host linux60805 port 3002, which means we'd go to:

Further Reading

To actually do something useful with Rails, see your class handouts and/or visit:

Personal tools