Ruby On Rails
Installing Ruby on Rails 2.x in your User-Home
Ruby on Rails is a free web application framework that aims to increase the speed and ease with which database-driven web sites can be created and offers skeleton code frameworks (scaffolding) from the outset. Often shortened to Rails, or RoR, Ruby on Rails is an open source project written in the Ruby programming language and applications using the Rails framework are developed using the Model-View-Controller design pattern.
You can learn more about ithere.
Installation and source build has to be done on a 32-bit Linux computer Verify the system type you are working on with the "uname" command.
1. Set some Variables first
export GEM_HOME="$HOME/pack/rubygems" export RUBYLIB="$HOME/pack/rubygems/lib" export PATH="$GEM_HOME/bin:$PATH"
2. Get Ruby GEMS
mkdir src cd src wget http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz gtar xvfz rubygems-1.2.0.tgz cd rubygems-1.2.0 mkdir -p $GEM_HOME
3. Have a look at "ruby setup.rb --help" to read about the many configuration switches
ruby setup.rb install --prefix=$GEM_HOME
4. Install ruby on rails (select all required packages for installation)
# GEM is the "apt-get"-tool for ruby packages # it has a package database which can be outdated or # corrupt. Remove it, if the ~/.gem directory exists # or you will be in trouble! # rm -rf ~/.gem cd $GEM_HOME/bin ./gem install rails --include-dependencies
5. Install the database driver for sqlite (choose the last version number)
./gem install sqlite3-ruby -- --with-sqlite3-dir=/usr/pack/sqlite-3.2.2-mo/ --with-sqlite3-lib=/usr/pack/sqlite-3.2.2-mo/i686-debian-linux3.1/lib/
6. Install the database driver for mysql
./gem install mysql -- --with-mysql-dir=/usr/pack/mysql-5.0.51-sd/ --with-mysql-lib=/usr/pack/mysql-5.0.51-sd/i686-debian-linux3.1/lib/mysql
7. Test it
mkdir -p $HOME/proj/rails cd $HOME/proj/rails
8. Create a new rails project
rails addressbook cd addressbook
9. Create model classes and database for the contacts
# create model contacts (note: here we write just "contact", rails # will append the "s" for "contacts" automatically ("pluralization") # in the corresponding database's table name. # if you write "contacts" here, the webinterface won't work! # in the "contacts" table, we create the columns "name" and "address", # both of type string (is created a VARCHAR in the real SQL table): # ./script/generate scaffold contact name:string address:string # # # this command will create the database db/development.sqlite3: # rake db:migrate # # # now we can add some sample data to our database: # (enter ".help" for instructions in sqlite3) # sqlite3 db/development.sqlite3 sqlite> insert into contacts (name, address) values ('Meier', 'Bergstrasse') ; sqlite> insert into contacts (name, address) values ('Moser', 'Ackerweg') ; sqlite> insert into contacts (name, address) values ('Mueller', 'Bachweg') ; sqlite> .quit
10. Edit the configuration file for the database config/database.yml
# the file database.yml should look like this # development: adapter: sqlite3 database: db/development.sqlite3 timeout: 5000
12. Start the embedded webrick webserver
ruby -rubygems script/server
14. Point your webbrowser to: yourhostname.ethz.ch:3000/contacts and enjoy
*** Note: In the URL we will also use a plural ("contacts") ***
Running your old Ruby On Rails applications under a new Rails version
This is a helpful trick provided by Till Quack (BIWI).
Download the corresponding old rails version from http://rubyforge.org/
- Copy the vendor/rails folder of the downloaded package into the toplevel folder of your old rails application. Rails will now use the "frozen" (old version) of rails when the application is run.