Master ruby with us

Archive for the ‘Blogroll’ Category

Git – create git branch

Posted by firstruby on November 2, 2008

Create new branch “demo” as,

1) git branch demo

This will create local branch “demo”

2) git checkout demo

This will switched to that branch

3) make some changes in that code, then,

git add <files>
git commit -m "<your message>"

4) git push origin demo

This will create new remote branch “demo” on github.

5) If you want someone to checkout the code from “demo” branch, then do following,

git clone <git-path>


git checkout --track -b demo origin/demo

Now, you are in “demo” branch.


Posted in Blogroll, firstruby, Useful Links | Tagged: , , | 1 Comment »

GIT with branches

Posted by firstruby on October 31, 2008

In SVN,  we can create standard repository structure like,
– trunk       – current code
– branches – versions
– tags
such as we can store the code in different branches in GIT,
git push origin demo1.0
where demo1.0 – name of the branch

Posted in Blogroll, firstruby, Useful Links | Tagged: , | Leave a Comment »

Ruby Gems

Posted by firstruby on February 4, 2007

Using Ruby Gems

You may want to add functionality to your application using Ruby Gems. A gem is a packaged Ruby application or library. A great introduction to Ruby Gems can be found here. Basically, Ruby Gems keep you from having to reinvent the wheel, by providing you with modular pieces of code that can be accessed from within your application’s code.

By default, some gems will come pre-installed with your hosting plan. Generally these are Rails-relevant gems (ActiveRecord, ActionMailer, etc.). To see a list of installed gems at any time, type “gem list –local” from an SSH window.

To install new gems, issue the command “gem install <gem-name>” (where <gem-name> is the name of the gem you wish to install). This command will first search your local machine for the specified gem, and if not found, will attempt to automatically download the gem from RubyForge, an online gem repository. Check RubyForge for a complete listing of available gems or check the link here for a more condensed listing. More installation options can be found by typing “gem install –help”.

By default, gems will be installed to ‘/usr/lib/ruby/gems/1.8/gems/’.

Freezing Ruby Gems

Whenever a new gem version appears on the host, your Rails application will attempt to automatically upgrade to that version. This is convenient when in development, but after moving to production, it can cause things to break unexpectedly. For obvious reasons, you don’t necessarily want your application being updated after it has been published. To prevent gems from updating, change directories to your application root, and issue the command “rake freeze_gems”. This copies the gems from /usr/lib/ruby/gems/1.8/gems/ (the default location) to <your-app-name>/vendor/ and keeps them from being automatically updated.There is one caveat with the “rake freeze_gems” command. It will only freeze gems that are Rails-relevant. If running this command doesn’t freeze the gem(s) you want it to, (i.e. they are not found in <app-name>/vendor/) you will need to use the solution found here.
This section is intended only to give a brief introduction to concept of freezing gems. If this is something you are interested in doing, it is highly recommended that you read up on the documentation at for more information.

Posted in Blogroll, firstruby, Useful Links | Leave a Comment »


Posted by firstruby on January 5, 2007

Getting Started

The easiest way to get started with Mongrel is to install it via RubyGems and then run a Ruby on Rails application. You can do this easily:

               gem install win32-service (pick the most recent one)
               gem install mongrel (pick the win32 pre-built)

Win32 Support

Win32 is fully supported by Mongrel with services and CPU affinity support.

The main thing with Win32 support is that there is no fork API for Ruby, so you have to use the services features to get persistent servers running. You can get this services support by doing:

              gem install mongrel_service

And then just run mongrel_rails to see what services:: commands are available.

Running The Service

After you do the gem install, find a Rails application you want to run and do:

$ mongrel_rails service::install -N myapp \\ 
       -c c:mypathtomyapp -p 4000 -e production 
       $ mongrel_rails service::start -N myapp

Now hit the port and poof, works (or should).

The application will stop if you use:

$ mongrel_rails service::stop -N myapp

NOTE: Stop reports an exception but does stop the service.

Now the really great thing is that you can just do all this from the Services control panel like your Rails application is a regular Windows service.

Even works in development mode, which is pretty nice.

Making you Service autostart with Windows

By default, the new Mongrel service get installed to be run manually, using Mongrel’s commands or the Service Manager. You could tweak it to start automatically when Windows start, just use the Service Control commandline tool:

$ sc config myapp start=auto

Also, you can configure the services that are neede to make it work, like database support:

$ sc config myapp start=auto dependency=MySql

CPU Affinity

Mongrel’s win32 support actually is able to set the CPU affinity of a running Mongrel service. This is pretty neat since it means if you’re running a fancy SMP machine or a dual core that pretends to be SMP, then you can force Mongrel onto one of them and get a nice little boost.

It’s pretty easy to use, just pass the -u or—cpu option to the install command and give a CPU of 1-X. That means if you have 4 CPUs and you want Mongrel on #4 then do:

$ mongrel_rails service::install -N myapp 
       -c c:mypathtomyapp -p 4000 -e production -u 4

Pretty much the same command, just one more option and you’re done.

Posted in Blogroll, firstruby, Useful Links | Leave a Comment »


Posted by firstruby on December 13, 2006

Welcome to learn Ruby,

Now you can download ‘Radrails (version 0.7.2)’ editor for developing Ruby On Rails application for Windows, Mac OSX and Linux at

Download Radrails 0.7.2

Posted in Blogroll, firstruby, Useful Links | Leave a Comment »