|
The wise student hears of the Rails way and embraces it
The average student hears of the Rails way and forgets it
The foolish student hears of the Rails way and laughs aloud
But if there were no laughter, there would be no Rails way
The Rails Way - Obie Fernandez
MY RESUME
My EEEPC subnotebook running Linux
Are We Having Fun Yet?How to Install Rails on Ubuntu
May 24, 2008
The instructions at Ruby on Rails don't work (www.rubyonrails.org/down).
There are a number of other things you have to do to make Rails 2.x work on Linux and any other
platform - in this case, it was about thirty other things. I found most of this information by googling
it. I have given attributions to the most important sources of information, but not all of them (thanks...).
This is what I had to do. Your mileage may vary.
First get Ubuntu Linux from releases.ubuntu.com.
I got version 7.10. The latest is 8.04 at the time of writing.
At the top of the monitor after installing and logging in to Ubuntu, you will see Applications.
Click on that, then select Accessories...Terminal. In the terminal, type these commands:
sudo apt-get install ruby
(enter password and answer Y to all questions)
sudo apt-get install mysql-client-5.0
Then go to
rubyforge.org/frs/?group_id=126
and download the latest rubygems-xxx.tgz. Unzip it like this:
tar xvfz rubygems-xxx.tgz
cd rubygems-xxx
sudo apt-get install rdoc
sudo ruby setup.rb
Again, the instructions are wrong. Just doing 'ruby setup.rb' won't work.
Then
sudo mv /usr/bin/gem1.8 /usr/bin/gem
cd ..
sudo gem install rails --include-dependencies
sudo apt-get install sqlite3
sudo apt-get install ruby1.8-dev
sudo apt-get install libmysql-ruby1.8
sudo apt-get install libmysqlclient15-dev
(that's a number fifteen in the middle)
sudo gem install mysql
sudo apt-get install mysql-server
It will ask for a MySQL password for 'root'. It's a good idea to
enter one, rather than just hitting enter, like I did.
sudo apt-get install build-essential
Ubuntu then asked me to insert the Ubuntu CD! Luckily, I still had
it. I thought only Windows did that!
sudo gem install mongrel
sudo apt-get install sqlite3 swig libsqlite3-ruby libsqlite3-dev
A hat-tip to
blog.rubypdf.com/2006/10/20/install-ruby-on-rails-lighttpdsqlite3-and-mongrel-under-ubuntu/
for that last command. Next
sudo gem install sqlite3-ruby
sudo apt-get install openssl
sudo apt-get install libssl-dev
sudo apt-get install libopenssl-ruby
sudo apt-get install libssl0.9.8
Now I recommend going to
fairleads.blogspot.com/
for detailed instructions on how to create a simple Rails app. The old
Agile Web Development with Rails 2nd edition is out of date, and Rails 2
is incompatible with it. By the time you read this, the 3rd edition may be out.
Ready? The next bit is more fun than the previous bit...
rails example
cd example
rake db:create:all
script/generate scaffold Movie title:string
rake db:migrate
script/server &
(The & makes the Ruby web server run in the background so you
can carry on using the terminal).
Now point your browser at localhost:3000/movies
and you should be able to click on 'New movie' to create a new movie in the database.
Currently, Rails uses SQLITE for development. You probably want a grown-up database as well,
so you might want to try MySQL.
mysql -u root
(enter password)
mysql> create database movies_development;
mysql> create database movies_test;
mysql> create database movies_production;
mysql> quit;
Now edit the file database.yml in the config folder in your Rails app to look like this
login: &login
adapter: mysql
username: root
password:
host: localhost
development:
<<: *login
database: movies_development
test:
<<: *login
database: movies_test
production:
<<: *login
database: movies_production
Thanks to blog.bleything.net/2006/06/27/dry-out-your-database-yml
for this tip.
Enterfgthen CONTROL-Cto stop the Rails server,
restart it, and create the database in MySQL:
script/server &
rake db:create:all
rake db:migrate
Got to localhost:3000/movies again and
see if you can create a movie using MySQL.
It sucks, doesn't it? Rails should be a lot easier to install than this. Like Perl modules.
It should be possible to get up and running in Rails without being a sysadmin.
Ruby's own package-management
system, GEM, is pretty good, but Linux packages are a cluster.
This page will get out of date pretty quickly (Ubuntu has already overtaken me)
but I'm not going to maintain an install script for numerous versions of Ubuntu,
let alone other operating systems. Somewhere out there there must be a geek who likes doing this
kind of thing...
|