The Hitchhiker’s Guide to Ruby On Rails Galaxy

Records of my voyage through RoR Galaxy

RubyConf India 2010 – India’s First Ruby Conference

Posted by arjunghosh on March 15, 2010


  The Ruby Community in India, together with the Innovation & Technology Trust, is pleased to announce RubyConf India 2010 on Mar 20, 21 at the Royal Orchid Hotel, Old Airport Road, Bangalore.

This dual-track event will feature prominent speakers like:        

Ruby is an OS dynamic language that offers an ideal development environment for Agile practitioners. It has one of the most active open source communities worldwide which produces and supports tools and projects like Ruby on Rails Рa powerful web application development framework that works well on different platforms, and significantly reduces time-to-market and operating costs.

Brainstorm, Network and Learn about the latest technology changes first-hand!

Follow us on twitter @rubyconfindia

  Platinum & Technology Sponsor:-   

Gold Sponsors:-
Castle Rock Research India

Castle Rock Research India is a part of Castle Rock Research Corporation, a premier educational resource development company headquartered in Edmonton, Canada, offering print and digital educational resources in K-12 and higher education market. We represent the technology division of Castle Rock Research Corp and our focus is to build technology-based educational products for North American market. Our products address evolving needs of three primary groups ‚Äď the student, the parent, and the education service providers, both in K-12 and higher education market.

Silver Sponsor:-
Mahashwami Software


I'm attending RubyConf India 2010


Posted in Uncategorized | Tagged: , , , , , , , , | 2 Comments »

How to parse a tweet text from Twitter using Ruby to parse-out ‘@’ and ‘#’

Posted by arjunghosh on March 5, 2009

Well lot of us love @twitter and also Ruby, and some time work on both ūüôā

And often we need to do the folowing with a tweet

Well I had to do the following quite often:-

Take out the ‘@’¬†(i.e. @replies )and ‘#’¬†(i.e. hashtags ) from a tweet and separate it from the text part.

For example, we have a tweet:

@myfriend1 @myfriend2 this is a sample text #link #text

Now I want this tweet to be seperated into the following Array:



and the text only – [“this is a sample text “]

So first had to build a RegE, and then using the ever useful .gsub method of Ruby, created the following:

parsed_text = tweet.text.gsub(/ ?(@\w+)| ?(#\w+)/) { |a| ((a.include?(‘#’)) ? tags : replies) << a.strip.gsub(/#|@/,”); ” }

So the parsed_text has the final text only.  tags is an Array which will contain the hashtags and replies is an Array which will contain the @replies.

The RegEx / ?(@\w+)| ?(#\w+)/ extracts and seperates the hashtags & the @replies and place them in two seperate arrays.

The RegEx¬†/#|@/,” only reples the ‘@’ and ‘#’ symbols in the extracted array elements.

And you can download it from Gist here

Also while working on creating the above regular expressions, I found this interesting RegEx testing site called which will help you write regular expressions very easily.

Posted in Uncategorized | Tagged: , , , , , , | 8 Comments »

A very hip & cool parenting site called lil’grams which is built on RubyOnRails!

Posted by arjunghosh on March 3, 2009

Just wanted to do a very quick post on this very new hip & cool site on parenting – lil’grams


And do you know what, its has been made in RubyOnRails!

Do check out this site. It the brain child of Greg Narain who is a well know serial entrepreneur & social media expert.

Already people are talking about it and when its yet to be launched!!

Actually people like NYTime, CNET, Mashable have been talking about lil’grams for sometime. Even KillerStartups has a mention.

There is also a buzz on twitter too ūüôā

Yes, some would say its been in making for quite sometime. But as they say patience has its virtue. Ultimately its a labour of love.

It been really a long journey for me personally too. Have been working on it for quite some time. I still  remember those days of sleepless night, long meeting, etc. 

Though I am yet to be a dad ūüôā (a.k.a am un-married), I too ¬†feel like a proud parent my self on the birth of lil’grams¬†¬†which I feel is¬†literally my baby!¬†

If you like (and also dont ūüôā ) do tell us about it¬†here which I assure will be promptly replied to ūüôā

Posted in Uncategorized | Tagged: , , , , , , | 9 Comments »

Two of the best help & guide sites for RubyOnRails and Ruby

Posted by arjunghosh on February 27, 2009

Well this is essentially a note to self and well to others too.
The best help documents online for Ruby On Rails and Ruby are these AJAXified websites which allows real-time searching of sytanx and commands.

For Ruby On Rails, it is:

And for Ruby, we have:

And the best part is you can even download them so that you can use it offline!

Another good resource for Rails documentaion and help guides is the newly created collaborative effort Rails Guide project. This was started by @lifo as a project to give the rails community a good documentaion which was painfully lacking till now. Since its a collaborative effort, you can participate here. There is even buzz about this project on @twitter

Posted in Uncategorized | Tagged: , , , , , , | Leave a Comment »

Using ERB as a dynamic template to create a file whose contents are dynamic

Posted by arjunghosh on February 17, 2009

The following code will create a temporary file for say attaching a vcard file to email.The following code is dynamic to use ERB as a template to create the file dynamically every time with the variable “telephone”,”location”,”email” which gets binded to the ERB file and is under scope.
The code is:-

telephone = “347-27456”
location = “New Delhi”
email = “”
vcard =‘address.vcard.erb’ ){ |f| } ).result( binding )
f =“temp_file.vcf”,”wb”)
f.puts vcard

and in pastie is here

Posted in Uncategorized | Tagged: , , , , , , , | 1 Comment »

Model name in RubyOnRails should ALWAYS be singular!!!

Posted by arjunghosh on December 23, 2008

Model names in RubyOnRails should be Singular. This will create Table name as corresponding Plural names.

You have got to remember that about model naming conventions in rails. . 

I know this is a very basic concept in RubyOnRails but sometimes these simple basic concepts are the ones which slip through the cracks.


> ruby script/generate model Post

This will create a Model by the name “Post” i.e. singular in english language¬†and a migration to create a table by the name “Posts” which is plural form of “Post”.

I have even put this into a pastie for easier remembarance

Posted in Uncategorized | Tagged: , , , , , | 7 Comments »

I am Back!!! and so many interesting changes to Rails…

Posted by arjunghosh on December 23, 2008

Yeah I know its been long since I have been away. Well lot has happened between my last journey¬† through RubyOnRail’s universe from May 28,2008 to the current date. New Rails 2.0 screencast by¬†Fabio Akita¬† which is unspired by¬†the¬†Creating a Weblog in 15 minutes¬†the original¬†screencast by David Hansson , Newer version of RubyOnRails (v 2.2.2) are out, Rails officially moved to GitHub and supports¬† Git as the VCS of choice, Rails thread safety¬†is in (though how is that actually useful ?),¬† lot of nifty changes in Rails v2.2.¬† So all in all lot of things have been happening.

I will try to be more regular here. In mean time, everyone who twitter and in New Delhi, India can check out the where I have been posting regular rubyonrail updates and local information. You can find me on twitter here at @arjunghosh.

Posted in Uncategorized | Tagged: , , , , , , , | Leave a Comment »

Going through a Design & Theme shift

Posted by arjunghosh on May 28, 2008

Right now am going through a design and Theme sift as the present theme is much better suited to display codes. So please be patient. Thanks ūüôā

Posted in Uncategorized | Tagged: , , | 2 Comments »

How to force the browser to not cache in Rails

Posted by arjunghosh on April 29, 2008

This is a quick note to self. Though,I found this excellent post by Chad while looking for something else but this post had a excellent note on browser cache also. So this post is mostly a re-post from Chad’s.

So here it goes:

To ensure that the page isn’t cached by the browser and will always be re-fetched, add a before_filter to the purchases controller which calls a private method on ApplicationController:

before_filter :no_cache, :only => [:new]
def no_cache
response.headers["Last-Modified"] =
response.headers["Expires"] = 0

# HTTP 1.0
response.headers["Pragma"] = "no-cache"

# HTTP 1.1 'pre-check=0, post-check=0' (IE specific)
response.headers["Cache-Control"] = 'no-store, no-cache, must-revalidate, max-age=0, pre-check=0, post-check=0'

Now there is a catch – ‚Äėnot caching‚Äô only works in Firefox.

Now the above code should have worked for all browser, but it did not work in Safari or in IE 6 and 7. The reason is that any page with an iframe on it will never be cached, and will always be re-fetched.

The solution is iframe. So, we add this to views/foo/new.

<iframe style="height:0px;width:0px;visibility:hidden" src="about:blank"> this frame prevents back forward cache </iframe>

This frame prevents back forward cache. And this works. Now we have cross-browser no-caching in a RESTful. Though this is a hack as Chad says. But it works for me. ūüôā

Posted in Uncategorized | Tagged: , , , | 6 Comments »

To make text in TextArea selectable onclick of mouse

Posted by arjunghosh on April 28, 2008

I am very sure most know about this and is a very simple thing. But as I have found sometimes that small things are the one which are missed.

So wanted a quick note on – How to make the text inside a textarea selectable on mouse click.

Well, we use the Javascript event system
[def: An event in Javascript is something that happens with or on the web page ].

Specifically we use the onclick Event to achieve the above stated goal. onClick applies to buttons (submit, reset, and button), checkboxes, radio buttons, and form upload buttons.

This is how we do it:

<textarea rows="3" cols="43" name="none" onclick=";">This is the text which when clicked on will get selected</textarea>

The main syntactic sugar here is the “onclick=”;”

Here the “this” helps us to access the textarea object and then we fire the DOM event “select()”
dynamically on it, which in turns selects the text inside the textarea.
ciao until next time ūüôā

Posted in Uncategorized | Tagged: , , , , | 6 Comments »