“The time has come…to talk of many [technologies].” –Lewis Carroll(‘The Walrus and the Carpenter’)
Archive for December, 2008
Setting Up Rails Development Environment on Fedora GNU/Linux
Dec 17th
This is an adaptation to Fedora GNU/Linux platform of my previous posts meant for the Windows & Ubuntu platforms: Setting Up Rails Development Environment on Windows Vista/XP and Setting Up Rails Development Environment on Ubuntu GNU/Linux.
I can think of two different ways in which you might want to set up a development environment for Ruby on Rails on a GNU/Linux machine. One is to download everything outside of the package manager of your distribution i.e. build everything from the source. I am going to cover the second, easier way: how to setup Rails on a Fedora machine using its package manager for the most part. I show below how to setup Ruby, RubyGems, Rails, Mongrel, MySQL, and Git as part of the development stack.
-
Installing Ruby:
Install the Ruby and related packages as root user:
# yum install ruby ruby-docs ruby-irb ruby-ri ruby-sqlite3 -
Installing Rubygems
Though it is possible to install Rubygems using the Fedora package manager, not only will you get an old version of rubygems if you do so, it also may not be compatible with the latest version of rails. I strongly recommend you download the source code package of the latest version of rubygems and install it using its setup script:
# cd $HOME
# wget http://rubyforge.org/frs/download.php/45906/rubygems-1.3.1.zip
# tar xvzf rubygems-1.3.1.tgz && cd rubygems-1.3.1
# ruby setup.rbRemember to download the latest version of rubygems available(currently 1.3.1). You can remove the downloaded tgz archive and the extracted directory after the installation is finished.
#cd $HOME
# rm -r rubygems-1.3.1.tgz rubygems-1.3.1 -
Installing Rails
Update all the gems(not really needed) and then install the rails gem.
# gem update –&ndashsystem
# gem install railsTo update rails in future, run ‘gem update rails’ command.
Check the versions to confirm installation:
# ruby -v
ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-linux]
# gem -v
1.3.1
# rails -v
Rails 2.2.2 -
Installing Mongrel
Installing the Rails gem also installs the WEBrick web server which is ideally suited for development purposes. Another much recommended web server for Rails development as well as production environment is the Mongrel web server. To install the Mongrel web server, run the following gem command:
# yum install mongrelAfter installing Mongrel, Rails automatically starts Mongrel instead of WEBrick web server when you run Rails applications in development mode. (Refer to Mongrel documentation to know more about running Rails applications under Mongrel in production mode.)
-
Installing MySQL
This step covers the installation of MySQL database server and its GUI tools. Skip this step if you want to use some other database server. Run the following command to install the required mysql packages:
# yum install mysql-server mysql-administrator mysql-gui-toolsOne important step during the configuration process is to select a root password(you will need to enter it in the database.yml configuration file of your Rails application).
-
Source Control
To setup your rails application using git source code management tool, see my other post:
Setting Up Ruby on Rails Projects with Git and GithubYou can also install cvs or subversion or other version control software using yum package manager.
# yum install cvs subversion
The basic Rails development environment is now installed on your system and you can skip the rest of the post if you are happy with WEBrick as the web server, SQLite as the database server and your favourite text editor/IDE that may be already installed on your system. The following instructions cover installing an alternate web server called Mongrel and MySQL database server and its GUI tools.
Now you can create/checkout Rails applications, edit the files using your favourite text editor/IDE and run it under Mongrel. In future, I will try to write about developing Rails applications using integrated development environments like Eclipse and NetBeans.
Setting Up Ruby on Rails Projects with Git and Github
Dec 9th
Git is the favourite source code management tool of the Ruby on Rails community these days. Though GNU/Linux or Mac platforms are generally preferred to Windows by Ruby on Rails as well as git communities, I will show you how you can work with these technologies on Windows platform. I will also show how to host a git public/share repository of a Rails application on the Github free web service. Note that the following information applies to any project, not just Rails.
- Refer to my earlier post to see how to install Ruby on Rails on the Windows platform. You can skip some of the later parts if you wish.
Setting Up Rails Development Environment on Windows Vista/XP
- Git still has some issues on the Windows platform but for normal usage the msysgit package shouldn’t let you down. Download and install it from its Google Code page.
Read the information in last few dialog boxes carefully during the installation and select the settings you prefer. The following screenshots show the settings I have picked when installing msysgit on my system.
Install a separate git shell in which to run the git commands:

I can go to any git initialized directory, right-click a file and say “Git Bash Here” which will save me a lot of ‘cd’ commands:

Git’s built-in SSH support is more than enough for development purposes:

Now you can just go to any Rails directory and run ‘git init’ there to track the files under git.
Start Git Bash shell from the Start Menu.

Go to your Rails directory and run the following commands.
Example session:
# cd hello
# ls
# git init
# git add .For more git commands that you can use, refer to Git Tutorial. To learn more about how Git handles line ending conversions(especially important to Windows users), refer to gitattributes man page.
- If you are working alone on a particular application or you are just interested in maintaining the history of the source code changes locally, then you might prefer just working with in the project directory. If I want to share the changes with friends/colleagues or the world at large, we need a public git repository. Github and Assembla are but only two examples that have good free packages to get started with.
Create a new account on Github.
- Go to github.com
- Click the link “Pricing and Signup” at the top of the page.

- Pick a package(say “Open source” which is free) and click “Signup” button.

- Fill in the information and click “I agree, sign me up!” button if you agree to all the policies.
You need to enter your public SSH key when creating a Github account. If you don’t already have SSH keys generated, you can generate one using git tools. Github website has nice explanation on how to go about setting up SSH key on Windows for Github, so just follow the procedure.
Once you have created the account and are logged in, click the “Create new one” link on the dashboard page, fill in the details and click the “Create Repository” button to create an empty repository on Github.

Now you can push the contents of your Rails directory to the empty git repository that we created on Github in the previous step by running the following command in Git Bash shell:
Adjust the second command according to your account/project details. Now you can say ‘git push’ from your git tracked directory anytime you want to publish your changes to Github, so that others can pull these changes to their computers and merge them with their local git repository.
I will try to write about more tools that help in being more productive with development with Rails in future articles.