Exercise 1 / Environment setup

Summary

  1. Make local development environment with a database from rails.cs.helsinki.fi
  2. Make almost that same to rails.cs.helsinki.fi so that username.rails.cs.helsinki.fi shows your application running at $HOME/rails
  3. You don't need to install any Gems to your (department) workstation OR rails.cs.helsinki.fi
  4. Everything that runs at rails.cs.helsinki.fi is in "production" so all commands needs to have RAILS_ENV=production environment variable set + database config is read under "production"

Environment

Developing Rails requires your own, local, environment and preferably some more stable area to test out your application and to present it to others.

Local

To develop Rails you need local development environment. All workstations at department have been pre-configured. If you want to use your own environment (recommended), see notes in this document and or google "windows ruby on rails".

Production / Staging

You can use your own server in your closet or use rails.cs.helsinki.fi

rails.cs.helsinki.fi

For this course we have rails.cs.helsinki.fi virtual server. It's accessible only the CS Depts network. Use ssh-tunnels or such if you need to access it from outside.

Notes about CS depts workstations

(Currently) you need to have these environment variables set for Rails related commands:

export RUBYLIB=$RUBYLIB:/opt/rubygems-1.3.5/lib
export GEM_HOME=/opt/rubygems-1.3.5/gems
export PATH=$PATH:/opt/rubygems-1.3.5/bin:/opt/rubygems-1.3.5/gems/bin (UPDATED)
	

Notes about environment setup

Some notes for your closet or general interest.

Ruby

Ruby interpreter is usually provided as system package. Currently it's safe bet to use MRI.

Any version above 1.8.6 patchlevel > 100 should be good. Ruby 1.9. or jRuby should also work.

RubyGems

Package management for Ruby. Latest RubyGems is always needed.

Depends on two environment settings: $RUBYLIB and $GEM_HOME. If you wish to install RubyGems in other directory than default then you need to specify these variables.

Gems

Install with: gem install name-of-the-gem

Required and suggested gems:

Database connection adapters:

Cucumber testing

Database

Select a database that you are familiar with. I would recommend PostgreSQL.

Database on rails.cs.helsinki.fi

After logging, wait 1-3minutes, after that there should be mysql/postgres-password.txt in your home directory.

Postgres

Automatically generated database is named after your username.

MySQL

Automatically generated database is named after your username.

Database on db.cs.helsinki.fi

It is possible to run database on alkokrunni, but please use rails.cs.helsinki.fi. These instructions are just for situations where you need to test somethings / primary service is down for some reason.

On which port does the instance port?

Run /usr/local/sbin/userport <service> to get port number for your account and service, e.g. /usr/local/sbin/userport postgres

Postgres

MySQL

MySQL runs from $HOME/mysql/ and configuration is at$HOME/.my.cnf

Do not start MySQL with start-mysql, as it has networking disabled by default!

Oracle

Using Oracle with Rails is a bit hard, so let's not use it :)

Rails, finally we meet.

After setup we can finally actually do something.

Local environment

Local editor / IDE

Unlike Java, Rails is typically developed with (advanced) text-editor.

Requirements

Some editors to choose from

Production / staging environment at rails.cs.helsinki.fi

Server is configured so that username.rails.cs.helsinki.fi will start Rails application of that user.

Setup for any Rails application at rails.cs.helsinki.fi:

Test this setup with test application:

Test application

So now the full stack should be ready.

Any local environment:

rails.cs.helsinki.fi: