Saturday, August 15, 2009

Ubuntu 9.04 : How to Install Ruby on Rails 2.3.3 [15th August 2009]

CCH : These are the steps that I took to install Ruby on Rails to an IBM Thinkpad with 1G RAM and a 75G Hard Disk and installed with Ubuntu 9.04.

Ruby installation

Firstly, I clicked Applications/Accessories/Terminal to launch the Terminal and typed the following command to update the repositories.
sudo apt-get update
next, to upgrade the system :-

sudo apt-get dist-upgrade
The installation took afew minutes and also required approximately 100 MB disk space.
On succesful updating, I started to install Rails.
sudo apt-get install ruby ri rdoc irb libopenssl-ruby ruby-dev

Note : Rails prerequisites include :-
ruby = An interpreter of object-oriented scripting language Ruby
ri = Ruby Interactive reference
rdoc = Generate documentation from ruby source files
irb = Interactive Ruby

Ruby Gem installation

Next, I started to install the Ruby gem package manager by firstly downloading ad the latest Ruby gems .35 via the following link.
http://rubyforge.org/projects/rubygems/

Download and extract the files.
tar xvzf rubygems-1.3.5.tgz
cd rubygems-1.3.5
sudo ruby setup.rb

I then deleted the .tgz file and rubygems directory.
cd ..
rm -r rubygems-1.3.5 rubygems-1.3.5.tgz

Next, I set out to create a set of simlinks. Otherwise it will be a tedious task to type commands with the version (1.8). For an example if we need to call the gem command we’ve to type gem1.8.

sudo ln -s /usr/bin/gem1.8 /usr/local/bin/gem
sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb

Rails Installation

I then installed Rails using gem.
sudo gem install rails

Server Installation

FYI, Rails by default comes with the WEBrick server. But like most Rails developers, I prefer the Mongrel server and typed the following command to install Mongrel server as well as passenger 2.2.4 and capistrano 2.5.8 for deployemnt purposes

sudo gem install mongrel passenger capistrano
TIP : If you got any error while installing the Mongrel server, install the ruby-dev / ruby1.8-dev and try again.
sudo apt-get install ruby-dev
Database Installation
Rails 2.3 shipped with SQLite3 as it’s default database instead of MySQL. You can install SQLite3 libraries by following commands.
sudo apt-get install sqlite3 swig libsqlite3-ruby libsqlite3-dev
sudo gem install sqlite3-ruby
Since I prefer MySQL,
sudo apt-get install mysql-client libmysqlclient15-dev
sudo gem install mysql

Create Ruby on Rails App

With no error mesages, I proceeded to create a new Ruby on Rail application by following command :-

rails test_app
As I needed MySQL support, I typed :

rails test-app -d mysql

Run the app

cd test_app
script/server
I then point FireFox to http://localhost:3000
and bingo I succeeded in launching my first RoR apps on Ubuntu :-)

Ubuntu 9.04 : How to use the Terminal ?

Finally, after my last foray (in 2007) into developing RoR applications in Windows, I finally decided to do so in Linux.

Would you believe it, it took a retiree who loves to try out new operating systems to convince me to try out Ubuntu 9.04 ? He actually prefers Mandriva Spring 2009 :-)

So using my usual modus operandi, I googled for 'How to install ruby and ruby on rails on ubuntu 9.04" and got http://mohamedaslam.com/install-ruby-on-rails-on-ubuntu-904-jaunty-jacklope/

Let's see what are the steps

Ruby installation

First we need to update the repositories.
sudo apt-get update

Er... what's sudo and more importantly where do I type it ?

Did a further search and came across something called the Terminal and landed on https://help.ubuntu.com/community/UsingTheTerminal

which says :-
"Under Linux there are GUIs (graphical user interfaces), where you can point and click and drag, and hopefully get work done without first reading lots of documentation. The traditional Unix environment is a CLI (command line interface), where you type commands to tell the computer what to do. That is faster and more powerful, but requires finding out what the commands are."
-- from man intro(1)
For some tasks, especially things like system configuration, it makes sense to use the terminal, and you'll probably have seen instructions on help pages or forums similar to:
sudo gobbledegook blah_blah -w -t -f aWkward/ComBinationOf/mixedCase/underscores_strokes/and.dots

It is often assumed that you know how to use the terminal - and anyone can manage typing and backspacing. But there are some crafty shortcuts which can make your life a lot easier:
  • How to move around in a terminal window and edit the text that you type there.
  • Some Linux commands for basic tasks.
  • Different ways to open a terminal, how to work with multiple terminals, etc.

Using this page


  • This page will help familiarize you with basic GNU/Linux shell commands.
  • It is not intended to be a complete guide to the command line, just an introduction to complement Ubuntu's graphical tools.

  • All command names will be in bold.

  • Commands needing to be typed will be in "bold with quotes".
  • All of the commands on this page are to be issued from a command prompt in a terminal.

  • Note that the terminal is case sensitive. User, user, and USER are all different to Linux.

Starting a Terminal


In Gnome (Ubuntu)


The terminal can be found at Applications menu -> Accessories -> Terminal.

In Xfce (Xubuntu)


The terminal can be found at Applications menu -> System -> Terminal.

In KDE (Kubuntu)


The terminal can be found at KMenu -> System -> Terminal Program (Konsole).

Commands


sudo: Executing Commands with Elevated Privileges



  • Most of the following commands will need to be prefaced with the sudo command if you will be working with directories or files not owned by your account. This is a special command which temporarily gives you access to change computer settings. The terminal will ask you for your password. Please see RootSudo for information on using sudo.

File & Directory Commands



  • pwd: The pwd command will allow you to know in which directory you're located (pwd stands for "print working directory"). Example: "pwd" in the Desktop directory will show "~/Desktop". Note that the Gnome Terminal also displays this information in the title bar of its window.

  • ls: The ls command will show you the files in your current directory. Used with certain options, you can see sizes of files, when files were made, and permissions of files. Example: "ls ~" will show you the files that are in your home directory.

  • cd: The cd command will allow you to change directories. When you open a terminal you will be in your home directory. To move around the file system you will use cd. Examples:

    • To navigate into the root directory, use "cd /"

    • To navigate to your home directory, use "cd" or "cd ~"

    • To navigate up one directory level, use "cd .."

    • To navigate to the previous directory (or back), use "cd -"

    • To navigate through multiple levels of directory at once, specify the full directory path that you want to go to. For example, use, "cd /var/www" to go directly to the /www subdirectory of /var/. As another example, "cd ~/Desktop" will move you to the Desktop subdirectory inside your home directory.

  • cp: The cp command will make a copy of a file for you. Example: "cp file foo" will make a exact copy of "file" and name it "foo", but the file "file" will still be there. If you are copying a directory, you must use "cp -r directory foo" (copy recursively).

  • mv: The mv command will move a file to a different location or will rename a file. Examples are as follows: "mv file foo" will rename the file "file" to "foo". "mv foo ~/Desktop" will move the file "foo" to your Desktop directory but will not rename it. You must specify a new file name to rename a file.
    • To save on typing, you can substitute '~' in place of the home directory.

    • Note that if you are using mv with sudo you can use the ~ shortcut, because the terminal expands the ~ to your home directory. However, when you open a root shell with sudo -i or sudo -s, ~ will refer to the root account's home directory, not your own.

  • rm: Use this command to remove or delete a file in your directory.

  • rmdir: The rmdir command will delete an empty directory. To delete a directory and all of its contents recursively, use rm -r instead.

  • mkdir: The mkdir command will allow you to create directories. Example: "mkdir music" will create a directory called "music".

  • man: The man command is used to show you the manual of other commands. Try "man man" to get the man page for man itself. See the "Man & Getting Help" section down the page for more information.

System Information Commands



  • df: The df command displays filesystem disk space usage for all mounted partitions. "df -h" is probably the most useful - it uses megabytes (M) and gigabytes (G) instead of blocks to report. (-h means "human-readable")

  • du: The du command displays the disk usage for a directory. It can either display the space used for all subdirectories or the total for the directory you run it on. Example:
user@users-desktop:~$ du /media/floppy
1032    /media/floppy/files
1036    /media/floppy/
user@users-desktop:~$ du -sh /media/floppy
1.1M    /media/floppy/


  • -s means "Summary" and -h means "Human Readable"

  • free: The free command displays the amount of free and used memory in the system. "free -m" will give the information using megabytes, which is probably most useful for current computers.

  • top: The top command displays information on your Linux system, running processes and system resources, including CPU, RAM & swap usage and total number of tasks being run. To exit top, press "q".

  • uname -a: The uname command with the -a option prints all system information, including machine name, kernel name & version, and a few other details. Most useful for checking which kernel you're using.

  • lsb_release -a: The lsb_release command with the -a option prints version information for the Linux release you're running, for example:
user@computer:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 6.06 LTS
Release:        6.06
Codename:       dapper


  • ifconfig reports on your system's network interfaces.

Adding A New User



  • "adduser newuser" command will create a new general user called "newuser" on your system, and to assign a password for the newuser account use "passwd newuser".

Options


The default behaviour for a command may usually be modified by adding a --option to the command. The ls command for example has an -s option so that "ls -s" will include file sizes in the listing. There is also a -h option to get those sizes in a "human readable" format.
Options can be grouped in clusters so "ls -sh" is exactly the same command as "ls -s -h". Most options have a long version, prefixed with two dashes instead of one, so even "ls --size --human-readable" is the same command.

"Man" and getting help


/!\ man command, info command and command --help are the most important tools at the command line.
Nearly every command and application in Linux will have a man (manual) file, so finding them is as simple as typing "man "command"" to bring up a longer manual entry for the specified command. For example, "man mv" will bring up the mv (Move) manual.
Move up and down the man file with the arrow keys, and quit back to the command prompt with "q".
"man man" will bring up the manual entry for the man command, which is a good place to start!
"man intro" is especially useful - it displays the "Introduction to user commands" which is a well-written, fairly brief introduction to the Linux command line.
There are also info pages, which are generally more in-depth than man pages. Try "info info" for the introduction to info pages.
Some software developers prefer info to man (for instance, GNU developers), so if you find a very widely used command or app that doesn't have a man page, it's worth checking for an info page.
Virtually all commands understand the -h (or --help) option which will produce a short usage description of the command and it's options, then exit back to the command prompt. Try "man -h" or "man --help" to see this in action.
Caveat: It's possible (but rare) that a program doesn't understand the -h option to mean help. For this reason, check for a man or info page first, and try the long option --help before -h.

Searching for man files


If you aren't sure which command or application you need to use, you can try searching the man files.

  • man -k foo will search the man files for foo. Try "man -k nautilus" to see how this works.

    • Note that this is the same as doing apropos command.

  • man -f foo searches only the titles of your system's man files. Try "man -f gnome", for example.

    • Note that this is the same as doing whatis command.

Other Useful Things


Prettier Manual Pages


Users who have Konqueror installed will be pleased to find they can read and search man pages in a web browser context, prettified with their chosen desktop fonts and a little colour, by visiting man:/command in Konqueror's address bar. Some people might find this lightens the load if there's lots of documentation to read/search.

Pasting in commands


Often, you will be referred to instructions that require commands to be pasted into the terminal. You might be wondering why the text you've copied from a web page using ctrl+C won't paste in with ctrl+V. Surely you don't have to type in all those nasty commands and filenames? Relax. Middle Button Click on your mouse (both buttons simultaneously on a two-button mouse) or Right Click and select Paste from the menu.

Save on typing


Up Arrow or ctrl+p
Scrolls through the commands you've entered previously.

Down Arrow or ctrl+n
Takes you back to a more recent command.

Enter
When you have the command you want.

tab
A very useful feature. It autocompletes any commands or filenames, if there's only one option, or else gives you a list of options.

ctrl+r
Searches for commands you've already typed. When you have entered a very long, complex command and need to repeat it, using this key combination and then typing a portion of the command will search through your command history. When you find it, simply press Enter.

History
The history command shows a very long list of commands that you have typed. Each command is displayed next to a number. You can type !x to execute a previously typed command from the list (replace the X with a number). If you history output is too long, then use history | less for a scrollable list.

Change the text


The mouse won't work. Use the Left/Right arrow keys to move around the line.
When the cursor is where you want it in the line, typing inserts text - ie it doesn't overtype what's already there.
ctrl+a or Home
Moves the cursor to the start of a line.

ctrl+e or End
Moves the cursor to the end of a line.

ctrl+b
Moves to the beginning of the previous or current word.

ctrl+k
Deletes from the current cursor position to the end of the line.

ctrl+u
Deletes the whole of the current line.

ctrl+w
Deletes the word before the cursor.

More ways to run a terminal


You can also get it with a function key
You can run more than one - in tabs or separate windows

More Information



  • AptGetHowto - using apt-get to install packages from the command line.

  • Commandline Repository Editing - adding the Universe/Multiverse repositories through the command line.

  • grep Howto - grep is a powerful command line search tool.

  • find Howto - locate files on the command line.

  • CommandlineHowto - longer and more complete than this basic guide, but still unfinished.

  • HowToReadline - information on some more advanced customization for the command line.
For more detailed tutorials on the Linux command line, please see:

Thursday, July 30, 2009

Rails Documentation : Ruby on Rails guides

CCH : From the Net


These guides are designed to make you immediately productive with Rails, and to help you understand how all of the pieces fit together. There are two different versions of the Guides site, and you should be sure to use the one that applies to your situation:

Friday, April 24, 2009

Announcements : Rails 2.3: Templates, Engines, Rack, Metal, much more!


Posted by David March 16, 2009 @ 02:39 PM

Rails 2.3 is finally done and out the door. This is one of the most substantial upgrades to Rails in a very long time. A brief rundown of the top hitters:
  • Templates: Allows your new skeleton Rails application to be built your way with your default stack of gems, configs, and more.
  • Engines: Share reusable application pieces complete with routes that Just Work, models, view paths, and the works.
  • Rack: Rails now runs on Rack which gives you access to all the middleware goodness.
  • Metal: Write super fast pieces of optimized logic that routes around Action Controller.
  • Nested forms: Deal with complex forms so much easier.
And that’s just the tip of the iceberg. We’ve put together a complete guide for the Rails 2.3 release notes with much more information. Be sure to checkout the section on what was deprecated when you’re ready to upgrade your application.
You install 2.3 with (the final version is marked 2.3.2):
gem install rails

If you’re running on Passenger, be sure to upgrade to 2.1.2 as well. Rails 2.3 doesn’t run on older versions of Passenger!
We hope you’ll love it.

Tuesday, February 17, 2009

Announcements : Radrails 1.1.2 Released

by cwilliams » Wed Feb 04, 2009 9:45 pm


RadRails 1.1.2 has been released to stable. Users who are on 1.1.1 are recommended to upgrade. Aptana should prompt you to automatically upgrade if you're on 1.1.1. To manually install (for users of older releases, or those experiencing problems) the update site is: http://update.aptana.com/update/rails/3.2/


The changelog for this release is at: http://support.aptana.com/asap/browse/ROR/fixforversion/10153


This is a bugfix only release.

Monday, February 16, 2009

Announcements : Rails 2.3.0 RC1 - Relesed on 1 February 2009


Rails 2.3.0 RC1: Templates, Engines, Rack, Metal, much more!

Posted by David February 01, 2009 @ 11:40 PM

Rails 2.3 is almost ready for release, but this package is so stock full of amazing new stuff that we’re making dutifully sure that everything works right before we call it official.
So please help us do thorough testing of this release candidate. Lots of the underpinnings changed. Especially the move to Rack. So we need solid testing and will probably have a slightly longer than average release candidate phase to account for that.
But boy will it be worth it. This is one of the most substantial upgrades to Rails in a very long time. A brief rundown of the top hitters:
  • Templates: Allows your new skeleton Rails application to be built your way with your default stack of gems, configs, and more.
  • Engines: Share reusable application pieces complete with routes that Just Work, models, view paths, and the works.
  • Rack: Rails now runs on Rack which gives you access to all the middleware goodness.
  • Metal: Write super fast pieces of optimized logic that routes around Action Controller.
  • Nested forms: Deal with complex forms so much easier.
And that’s just the tip of the iceberg. We’ve put together a complete guide for the Rails 2.3 release notes with much more information.
You can install the release candidate with:
gem install rails --source http://gems.rubyonrails.org

Enjoy, report the bugs, and let’s get Rails 2.3 final out the door soon.

Announcements : Rails 2.2 is Released on 21 December 2008


Rails 2.2: i18n, HTTP validators, thread safety, JRuby/1.9 compatibility, docs

Posted by David November 21, 2008 @ 05:22 PM

Rails 2.2 is finally done after we cleared the last issues from the release candidate program. This release contains an long list of fixes, improvements, and additions that’ll make everything Rails smoother and better, but we also have a number of star player features to parade this time.

Internationalization by default
The most important is that Rails now includes a full-on internationalization framework and that it’s pre-wired from start. The work of the i18n group has been very impressive and it’s great to see that Rails finally ships with a solution in the box that’s both simple and extensible. Great job, guys!

Stronger etag and last-modified support
We’ve also added much better support for HTTP validators in the form of etag and last-modified. Making it so much easier to skip expensive procesesing if the client already has the latest stuff. This also makes it even easier to use Rails with gateway proxies.

Thread safety and a connection pool
Josh Peek has added thread safety to Rails and Nick Sieger from JRuby worked on getting Active Record a proper connection pool. So now all elements of Rails are thread safe, which is a big boon for the JRuby guys in particular. For C Ruby, we still need a bunch of dependent libraries to go non-blocking before it’ll make much of a difference, but work on that is forth coming.

Ruby 1.9 and JRuby compatibility
Jeremy Kemper has been rocking on both Ruby 1.9 and JRuby compatibility. Rails 2.2 is fully compatible with both, but again, there might be supporting libraries and gems that are not. Again, lots of work is going into making everything else fully compatible as well.

Better API docs, great guides
Finally, the last big push has been with the documentation of Rails. Pratik’s docrails project has made immense progress. Not only are the API docs much improved, but we also have a wholenew guides section generated from documentation that now lives with the source. A true community project with lots of contributors. I’m sure both those new and old to Rails will greatly appreciate the strong focus on documentation.
To read about all these features and more in details, checkoutthe Rails 2.2 release notes—another one of those guides from the docrails project.

How to install
As always, you can install Rails 2.2 through RubyGems. We now require RubyGems 1.3.1, so be sure to update that first: gem update --system

Then you can install Rails: gem install rails
If you’re updating an existing application, you can run rake rails:update to get the latest JavaScript files and scripts.
From all of us to all of you, we hope you enjoy this release. It’s a true pleasure to see Rails make such big steps forward once again. Dig in, have fun, and we’ll be back with Rails 2.3 with even more before you know it.

Welcome to Rails.. Rails... Rails !

In 1995, I started the popular Clipper...Clipper... Clipper website (no blogs then) which was very popular and linked by virtually every Clipper-related site. When I switched to Windows via Delphi in 1997, I started the Delphi... Delphi... Delphi site. In June 2007, I discovered Ruby on Rails and no prize for guessing what I am gonna name this blog. which I started on 2nd October 2007.

As at 10th June 2010, we have 13,364 unique visitors from more than 84 countries such as Angola, Andorra, Argentina, Australia, Austria, Algeria,Barbados, Bosnia and Herzogovina, Belgium, Brazil, Bulgaria, Bangladesh, Belarus, Bolivia, Chile, Cambodia, Cape Vede, Canada, China, Colombia, Costa Rica, Croatia, Cyprus, Czech Republic, Denmark, Egypt, Estonia, Finland, France, Guadeloupe, Guatemala, Germany, Greece, Hong Kong, Hungary, India, Indonesia, Ireland, Israel, Italy, Japan, Kenya, Korea, Lithuania, Latvia, Malaysia, Mexico, Macao, Netherlands, Nepal, Norway, New Zealand, Oman, Panama, Peru, Poland, Portugal,Paraguay , Philippines, Romania, Russian Federation, Saudi Arabia, Singapore, Spain, Slovakia, Slovenia, Serbia, South Korea, Slovenia, South Africa, Spain, Switzerland, Sri Lanka, Sweden, Taiwan, Thailand, Turkey, United Arab Emirates, Ukraine, USA, UK, Venezuela, Vietnam

CCH
10th June 2010, 19:42