<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Puneet Pandey&#039;s Weblog</title>
	<atom:link href="http://puneetitengineer.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://puneetitengineer.wordpress.com</link>
	<description>A Web Blog for All Ruby on Rails Developers</description>
	<lastBuildDate>Sun, 17 Jul 2011 07:06:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='puneetitengineer.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Puneet Pandey&#039;s Weblog</title>
		<link>http://puneetitengineer.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://puneetitengineer.wordpress.com/osd.xml" title="Puneet Pandey&#039;s Weblog" />
	<atom:link rel='hub' href='http://puneetitengineer.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Learn Core Ruby Concepts</title>
		<link>http://puneetitengineer.wordpress.com/2011/05/22/learn-core-ruby-concepts/</link>
		<comments>http://puneetitengineer.wordpress.com/2011/05/22/learn-core-ruby-concepts/#comments</comments>
		<pubDate>Sun, 22 May 2011 19:48:24 +0000</pubDate>
		<dc:creator>Puneet Pandey</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Core Ruby]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Ruby Concepts]]></category>
		<category><![CDATA[Ruby metaprogramming]]></category>

		<guid isPermaLink="false">http://puneetitengineer.wordpress.com/?p=128</guid>
		<description><![CDATA[Hello Everyone, We all know basic concepts of Ruby, like classes, objects, methods etc. etc and we integrate this with the concept of rails beautifully. In short I can say we all are very good at Ruby on Rails, and rails specially, but when it comes to Ruby, we are not that much confident tough. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=128&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello Everyone,</p>
<p>We all know basic concepts of <strong>Ruby</strong>, like <strong>classes</strong>, <strong>objects</strong>, <strong>methods</strong> etc. etc and we integrate this with the concept of rails beautifully.</p>
<p>In short I can say we all are very good at <strong>Ruby on Rails</strong>, and rails specially, but when it comes to Ruby, we are not that much confident tough.</p>
<p>In this Post of mine, we will cover all the important concepts of Ruby, some pure ruby code, and how we can apply this with Rails.</p>
<p>So let&#8217;s start learning the <strong>Core Ruby Concepts</strong>.</p>
<ul>
<li>In RoR programming, most of the times we need to identify the type of string. We don&#8217;t know if the incoming string is a &#8220;Integer&#8221;, &#8220;Float&#8221;, &#8220;String&#8221;. To check that:<br />
    <code>y = Incoming String<br />
              y.is_a?(Integer)  =&gt; returns true or false<br />
              y.is_a?(String)    =&gt; returns the same<br />
              y.is_a?(Fixnum)   =&gt; -----#-------<br />
              y.is_a?(Float)     =&gt; -----#-------<br />
    </code></p>
<ul>
<li>We can also ask the variable exactly what class of variable it is using the class method:<br />
        <code>y = "Incoming String"<br />
          y.class    =&gt; returns <strong>String</strong><br />
          y = 10.25<br />
          y.class    =&gt; returns <strong>Float</strong><br />
          y = 10     =&gt; returns <strong>Fixnum</strong><br />
        </code>
      </li>
<li>Sometimes we need to change the incoming string to say Integer (<strong>Note</strong>: It is for sure that in RoR application, when browser sends any parameter to any controller&#8217;s method, it will be string only), Float for further operations. To do that:<br />
       <code>x = "10.25"<br />
        y = x.to_f<br />
        p y.class    =&gt; returns <strong>Float</strong><br />
        z = y.to_i<br />
        p z.class    =&gt; returns <strong>Fixnum</strong><br />
       </code>
      </li>
</ul>
</li>
<li>Variable type: Ruby has four types of variables:
<ul>
<li>Local variable <strong>[a-z] or _</strong></li>
<li>Global Variable <strong>$</strong></li>
<li>Instance variable <strong>@</strong></li>
<li>Class variable <strong>@@</strong></li>
</ul>
<p>    To identify the type of variable, do:<br />
    <code>a = 10<br />
      p defined?(a)    =&gt; "local-variable"<br />
      $b = "Puneet"<br />
      p defined?($b)   =&gt; "global-variable"<br />
    </code>
  </li>
<li><strong>Metaprogramming:</strong> Metaprogramming is a technique in which code writes other code. The prefix <em>Meta</em> refers to <strong>Abstraction</strong>.
<ul>
<li>At a high level, metaprogramming is useful in working towards <em>DRY principle</em> (Don&#8217;t Repeat Yourself).</li>
<li>Metaprogramming is primarily about simplicity. One of the easiest ways to get a feel for metaprogramming is to look for repeated code and factor it out. Redundant code can be factored into functions; redundant functions or patterns can often be factored out through the use of metaprogramming.</li>
</ul>
</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puneetitengineer.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puneetitengineer.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/puneetitengineer.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/puneetitengineer.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/puneetitengineer.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/puneetitengineer.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/puneetitengineer.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/puneetitengineer.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/puneetitengineer.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/puneetitengineer.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/puneetitengineer.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/puneetitengineer.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/puneetitengineer.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/puneetitengineer.wordpress.com/128/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=128&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puneetitengineer.wordpress.com/2011/05/22/learn-core-ruby-concepts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9ffeee7fe7e3031d369d99673f06954?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Honey</media:title>
		</media:content>
	</item>
		<item>
		<title>Get Yourself Upto date with Ruby 1.9.2 and Rails 3</title>
		<link>http://puneetitengineer.wordpress.com/2010/12/21/get-yourself-upto-date-with-ruby-1-9-2-and-rails-3/</link>
		<comments>http://puneetitengineer.wordpress.com/2010/12/21/get-yourself-upto-date-with-ruby-1-9-2-and-rails-3/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 15:31:36 +0000</pubDate>
		<dc:creator>Puneet Pandey</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Rails 3]]></category>
		<category><![CDATA[Ruby 1.9.2]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://puneetitengineer.wordpress.com/?p=124</guid>
		<description><![CDATA[Hello Everyone, Today, where lots of people are shifting from older versions of ruby to the newer and stable one i.e 1.9.2 and rails 3. I am also shifting to this, and would like to share my thoughts and opinions about upgrading, its advantages, hurdles and future concerns. To try this.. I am using both [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=124&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello Everyone,</p>
<p>Today, where lots of people are shifting from older versions of ruby to the newer and stable one i.e 1.9.2 and rails 3. I am also shifting to this, and would like to share my thoughts and opinions about upgrading, its advantages, hurdles and future concerns.</p>
<p>To try this.. I am using both Linux (Ubuntu) and Windows (windows 7).<br />
Let&#8217;s cover each topic in detail</p>
<ul>
<li>Setting up Ruby-1.9.2</li>
<li>What&#8217;s new in Ruby-1.9.2</li>
<li>Few of the working ruby code</li>
<li>Setting up Rails-3 with Ruby-1.9.2</li>
<li>Setting up Passenger or Apache with Rails-3</li>
<li>A sample application in Ruby-1.9.2 and in Rails-3, featuring:
<ol>Authentication</ol>
<ol>Image Upload</ol>
<ol>Pagination</ol>
<ol>Facebook Integration</ol>
<ol>Twitter Integration</ol>
<ol>Google Earth integration</ol>
<ol>Post with Title and tags</ol>
</li>
</ul>
<p>I may cover this using different articles.</p>
<p>Meanwhile, there is an Rails-3 Application created by me, which is currently on Github. I would request, if someone is interested to see the changes Rails-3 has introduced, please download the application and run it on your local. Here is the path for it: <a href="https://github.com/puneetpandey/file_upload" target="_blank">https://github.com/puneetpandey/file_upload</a></p>
<p>Prerequisites:<br />
1. Ruby 1.8.7 or higher<br />
2. Rails-3<br />
3. Mysql Database</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puneetitengineer.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puneetitengineer.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/puneetitengineer.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/puneetitengineer.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/puneetitengineer.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/puneetitengineer.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/puneetitengineer.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/puneetitengineer.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/puneetitengineer.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/puneetitengineer.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/puneetitengineer.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/puneetitengineer.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/puneetitengineer.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/puneetitengineer.wordpress.com/124/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=124&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puneetitengineer.wordpress.com/2010/12/21/get-yourself-upto-date-with-ruby-1-9-2-and-rails-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9ffeee7fe7e3031d369d99673f06954?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Honey</media:title>
		</media:content>
	</item>
		<item>
		<title>Host Ruby on Rails Application on Heroku</title>
		<link>http://puneetitengineer.wordpress.com/2010/10/01/host-ruby-on-rails-application-on-heroku/</link>
		<comments>http://puneetitengineer.wordpress.com/2010/10/01/host-ruby-on-rails-application-on-heroku/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 12:13:27 +0000</pubDate>
		<dc:creator>Puneet Pandey</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Heroku]]></category>
		<category><![CDATA[Heroku Rails 3]]></category>
		<category><![CDATA[Host Rails 3 Application on Heroku]]></category>

		<guid isPermaLink="false">http://puneetitengineer.wordpress.com/?p=117</guid>
		<description><![CDATA[Hello Everyone, In this article we will cover how to run your rails-2+/3 application on Heroku. Requirements: 1. Heroku Account (http://heroku.com/) 2, Github Account (http://github.com/) 3. Heroku Gem (gem install heroku) 4. msysgit 5. Latest version of Git Steps: Step 1: Download msysgit and run it. Once the installation is finished. Create your SSH Public [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=117&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello Everyone,</p>
<p>In this article we will cover how to run your rails-2+/3 application on <strong>Heroku</strong>.</p>
<p>Requirements:<br />
1. <strong>Heroku Account</strong> (<a href="http://heroku.com/">http://heroku.com/</a>)<br />
2, <strong>Github Account</strong> (<a href="http://github.com/">http://github.com/</a>)<br />
3. <strong>Heroku Gem</strong> (<strong>gem install heroku</strong>)<br />
4. <a href="http://code.google.com/p/msysgit/downloads/detail?name=msysGit-fullinstall-1.7.2.3-preview20100911.exe&amp;can=2&amp;q=" target="_blank"><strong>msysgit</strong></a><br />
5. Latest version of <a href="http://code.google.com/p/msysgit/downloads/list"><strong>Git</strong></a></p>
<p><strong>Steps</strong>:<br />
Step 1: Download msysgit and run it. Once the installation is finished. Create your <strong>SSH Public key</strong> (if it has not created before.)<br />
Steps on creating SSH keys can be found <strong><a href="http://help.github.com/msysgit-key-setup/" target="_blank">here</a></strong>:<br />
Step 2: Once you&#8217;re done with SSH keys, Login into your <strong><a href="http://github.com/">Github</a></strong> Account and go to Account Settings -&gt; SSH Public Keys. Copy your id_rsa.pub key and paste it there.<br />
Step 3: Install latest version of Git, and make sure you have &#8220;<strong>checked</strong>&#8220;- access GIT via <strong>Command Line</strong>.<br />
Step 4: Install <strong>heroku gem</strong><br />
Step 5.a: If you&#8217;re committing your application for the first time in GIT, do these steps:<br />
5.a.1 <strong>git init</strong><br />
5.a.2 <strong>git add</strong><br />
5.a.3 <strong>git commit -m &#8220;my new app&#8221;</strong><br />
5.a.4 <strong>heroku create</strong><br />
5.a.5 <strong>git push heroku master</strong></p>
<p>During these steps, heroku will ask for your credentials. Give your username and password when asked. Once you&#8217;re done with all these steps, you can check &#8220;<strong>My Apps</strong>&#8221; under your Heroku Account. There you&#8217;ll find a link to access your application.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puneetitengineer.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puneetitengineer.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/puneetitengineer.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/puneetitengineer.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/puneetitengineer.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/puneetitengineer.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/puneetitengineer.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/puneetitengineer.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/puneetitengineer.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/puneetitengineer.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/puneetitengineer.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/puneetitengineer.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/puneetitengineer.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/puneetitengineer.wordpress.com/117/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=117&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puneetitengineer.wordpress.com/2010/10/01/host-ruby-on-rails-application-on-heroku/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9ffeee7fe7e3031d369d99673f06954?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Honey</media:title>
		</media:content>
	</item>
		<item>
		<title>Interesting Facts About Ruby</title>
		<link>http://puneetitengineer.wordpress.com/2010/03/29/interesting-facts-about-ruby/</link>
		<comments>http://puneetitengineer.wordpress.com/2010/03/29/interesting-facts-about-ruby/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 06:06:53 +0000</pubDate>
		<dc:creator>Puneet Pandey</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[DRY principle of RoR]]></category>
		<category><![CDATA[how to update ruby version on windows]]></category>
		<category><![CDATA[interesting facts about Ruby on rails]]></category>
		<category><![CDATA[Rails write less methodology]]></category>
		<category><![CDATA[Ruby on Rails Conventions]]></category>
		<category><![CDATA[update ruby 1.8.6 to 1.8.7 or higher]]></category>

		<guid isPermaLink="false">http://puneetitengineer.wordpress.com/?p=100</guid>
		<description><![CDATA[For all, who have started learning RoR and for those who are into this, here are some of the facts and conventions that you can follow, to make your Ruby code more shorter and easy to understand. Let&#8217;s look at it how: 1. This is how a beginner writes: if params[:email] @email_add = params[:email] else [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=100&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For all, who have started learning RoR and for those who are into this, here are some of the facts and conventions that you can follow, to make your Ruby code more shorter and easy to understand.</p>
<p>Let&#8217;s look at it how:</p>
<p>1. <em>This is how a beginner writes</em>:<br />
if params[:email]<br />
@email_add = params[:email]<br />
else<br />
@email_add = &#8220;Some Default Address&#8221;<br />
end</p>
<p>You should write in 1 line, let&#8217;s see how:<br />
<strong>@email_add = params[:email] ? params[:email] : &#8220;Some Default Address&#8221;</strong></p>
<p>2. <em>How to Improve the performance of any method inside your controller, if it is taking much time rather than the expecting.</em></p>
<p>Consider a scenario where we have one method, like:<br />
def index<br />
@users = User.find(:all)<br />
@members = Member.find(:all)<br />
@last_year_users = User.find(:all, :conditions =&gt; ["Some condition"])<br />
end</p>
<p>Now here suppose these queries returns data in a heavy size, definitely it will gonna take time to load, so how we will improve the performance in this case?</p>
<p>3 <strong>How to update ruby 1.8.6 to 1.8.7 or 1.9?</strong><br />
This makes me frustrated most of the times. I am having Ruby 1.8.6 as a stable version on my system. Now I want to update it to 1.8.7 so that I can sense Rails 3.0 and its features, but most of the sites and blogs are giving instructions to install it as a fresh copy and most of the sites are giving information that 1.8.7 is not compatible with rails 2.1 or higher.</p>
<p>So If someone knows how to upgrade, so that It won&#8217;t affect my existing apps running on 1.8.6 and it will install both copies of Ruby like rails does, please do post it here. I&#8217;ll be very thankful</p>
<p>4. <strong>Using polymorphic and as associations with models</strong><br />
Now, for most of the programmers, consider a scenario where multiple models has 1 to N relationship with one model. To make it more easier lets take 1 example.</p>
<p>Consider the following diagram:<br />
<a href="http://puneetitengineer.files.wordpress.com/2010/03/relationships.png"><img class="aligncenter size-full wp-image-108" title="relationships" src="http://puneetitengineer.files.wordpress.com/2010/03/relationships.png?w=570&#038;h=364" alt="" width="570" height="364" /></a><br />
Where models like School, College, Event and Semester are having multiple relationship with a single model i.e Student. Do you think, our student model will have foreign keys like school_id, college_id, event_id and semester_id? Will it be a good idea to have multiple foreign keys into one table?<br />
No it doesn&#8217;t make any sense. So whenever you have a scenario like this, you have to follow <strong>polymorphic</strong> and <strong>as</strong> associations. How? Let&#8217;s see:<br />
In Your models i.e school.rb, college.rb, semester.rb and event.rb, define something like this:</p>
<p>class School &lt; ActiveRecord::Base<br />
 	has_many :sc_students, :class_name =&gt; &#8220;Student&#8221;, :as =&gt; :rollable, :dependent =&gt; :destroy<br />
end</p>
<p>class College &lt; ActiveRecord::Base<br />
 	has_many :col_students, :class_name =&gt; &#8220;Student&#8221;, :as =&gt; :rollable, :dependent =&gt; :destroy<br />
end</p>
<p>class Semester &lt; ActiveRecord::Base<br />
 	has_many :sem_students, :class_name =&gt; &#8220;Student&#8221;, :as =&gt; :rollable, :dependent =&gt; :destroy<br />
end</p>
<p>class Event &lt; ActiveRecord::Base<br />
 	has_many :ev_students, :class_name =&gt; &#8220;Student&#8221;, :as =&gt; :rollable, :dependent =&gt; :destroy<br />
end</p>
<p>class Student &lt; ActiveRecord::Base<br />
 	belongs_to :rollable, :polymorphic =&gt; true<br />
end</p>
<p>So, what is the advantage here to use as association and polymorphic is, you don&#8217;t need to create school_id, college_id, semester_id and event_id columns in the students table. So when you create migration, you&#8217;ll have to create two columns i.e.</p>
<p>t.integer :rollable_id<br />
t.string :rollable_type</p>
<p>So for example colleges the entry will have rollable_id as specific college id and rollable_type as &#8220;College&#8221;. How simple and short implementation, isn&#8217;t it?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puneetitengineer.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puneetitengineer.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/puneetitengineer.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/puneetitengineer.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/puneetitengineer.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/puneetitengineer.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/puneetitengineer.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/puneetitengineer.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/puneetitengineer.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/puneetitengineer.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/puneetitengineer.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/puneetitengineer.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/puneetitengineer.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/puneetitengineer.wordpress.com/100/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=100&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puneetitengineer.wordpress.com/2010/03/29/interesting-facts-about-ruby/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9ffeee7fe7e3031d369d99673f06954?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Honey</media:title>
		</media:content>

		<media:content url="http://puneetitengineer.files.wordpress.com/2010/03/relationships.png" medium="image">
			<media:title type="html">relationships</media:title>
		</media:content>
	</item>
		<item>
		<title>Saving Arrays into Table</title>
		<link>http://puneetitengineer.wordpress.com/2010/01/27/saving-arrays-into-table/</link>
		<comments>http://puneetitengineer.wordpress.com/2010/01/27/saving-arrays-into-table/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 16:23:50 +0000</pubDate>
		<dc:creator>Puneet Pandey</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[ror arrays]]></category>
		<category><![CDATA[storing multiple arrays into the database with ror]]></category>
		<category><![CDATA[use index to store multiple arrays into the table ror]]></category>

		<guid isPermaLink="false">http://puneetitengineer.wordpress.com/?p=96</guid>
		<description><![CDATA[Well, this must be common to all, as all of us has implemented this kind of feature somewhere in our projects.. But I found it challenging couple of times to implement this.. so I thought to share this small piece of code with you. Hope it helps someone.. Requirement: In this small project we are [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=96&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well, this must be common to all, as all of us has implemented this kind of feature somewhere in our projects.. But I found it challenging couple of times to implement this.. so I thought to share this small piece of code with you. Hope it helps someone..</p>
<p>Requirement: In this small project we are going to <strong>store multiple arrays into the database</strong> as each array will create a new row.</p>
<p>Let&#8217;s see how it works..</p>
<p>Here is my view(in your case it could be any)</p>
<p>&lt;select name=&#8221;contacts_id[]&#8221; id=&#8221;contacts_id&#8221;&gt;<br />
&lt;% current_user.contacts.all.each do |contact| %&gt;<br />
&lt;%= contact.name %&gt;<br />
&lt;% end %&gt;<br />
 &lt;%= channel.name %&gt; </p>
<p>Now in this case we have two arrays one is for contact_id and another one is for channel_id, Let&#8217;s see how we will store those values into the table:</p>
<p>def create<br />
@contacts_channels = []<br />
params[:contact_id].each_with_index do |contact, i|<br />
@contacts_channels[i] = ContactChannel.new<br />
@contacts_channels[i].contact_id = contact_id<br />
@contacts_channels[i].channel_id = params[:channel_id][i]<br />
@contacts_channels[i].save<br />
end<br />
end</p>
<p>So what happens here? suppose you have an array of contact_id like this:<br />
contact_id = [4,5,6]<br />
and array of channel_id like this:<br />
channel_id = [10, 11, 12]</p>
<p>So with the above script your values should go into the table like this<br />
contact_id      channel_id<br />
4                     10<br />
5                     11<br />
6                     12</p>
<p>What makes me puzzled here is, in case of relationship here like<br />
Contact has_many :channels<br />
how will this exact scenario works?</p>
<p>Please let me know your feedbacks, suggestions and queries. Your comment means lot to me.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puneetitengineer.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puneetitengineer.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/puneetitengineer.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/puneetitengineer.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/puneetitengineer.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/puneetitengineer.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/puneetitengineer.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/puneetitengineer.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/puneetitengineer.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/puneetitengineer.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/puneetitengineer.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/puneetitengineer.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/puneetitengineer.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/puneetitengineer.wordpress.com/96/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=96&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puneetitengineer.wordpress.com/2010/01/27/saving-arrays-into-table/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9ffeee7fe7e3031d369d99673f06954?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Honey</media:title>
		</media:content>
	</item>
		<item>
		<title>rake aborted: no such file to load mysql</title>
		<link>http://puneetitengineer.wordpress.com/2009/09/24/rake-aborted-no-such-file-to-load-mysql/</link>
		<comments>http://puneetitengineer.wordpress.com/2009/09/24/rake-aborted-no-such-file-to-load-mysql/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 05:54:36 +0000</pubDate>
		<dc:creator>Puneet Pandey</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Could not find RubyGem rake-compiler (~> 0.5)]]></category>
		<category><![CDATA[mysql gem on windows]]></category>
		<category><![CDATA[Mysql::Error: query: not connected: CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB]]></category>
		<category><![CDATA[no such file to load mysql]]></category>
		<category><![CDATA[rake aborted: no such file to load mysql]]></category>
		<category><![CDATA[ruby-compiler]]></category>
		<category><![CDATA[ruby-mysql]]></category>
		<category><![CDATA[rubygems]]></category>
		<category><![CDATA[The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql]]></category>
		<category><![CDATA[trouble installing mysql gem on windows]]></category>

		<guid isPermaLink="false">http://puneetitengineer.wordpress.com/?p=93</guid>
		<description><![CDATA[Programmers who work mostly on windows have seen this kind of errors many times.. as a windows programmer I have been through many sites and collect d relevant data, now I am showing it to you.. The errors which might come to you something like this: no such file to load mysql rake aborted: no [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=93&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Programmers who work mostly on windows have seen this kind of errors many times.. as a windows programmer I have been through many sites and collect d relevant data, now I am showing it to you..</p>
<p>The errors which might come to you something like this:<br />
<strong>no such file to load mysql</strong><br />
<strong>rake aborted: no such file to load mysql</strong><br />
<strong>The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql</strong><br />
<strong>Could not find RubyGem rake-compiler (~&gt; 0.5)</strong></p>
<p>To solve such problems follow these steps:<br />
Step 1. Update rubygems to the latest version(like I upgraded it to 1.3.5).<br />
Step 2: install rake-compiler(by gem install rake-compiler).<br />
Step 3: if already installed hoe gem update it(gem update hoe) or install a fresh one.<br />
Step 4: Download libMySQL.dll from <a href="http://forums.aptana.com/viewtopic.php?f=20&amp;t=7563&amp;p=27407&amp;hilit=libmysql.dll#p27407" target="_blank">here</a> and copy it into C:/ruby/bin or wherever your ruby is installed, but make sure it should be in bin directory.<br />
Step 5: Stop the mysql service, from Control Panel -&gt; Administrative tools -&gt; services -&gt; mysql, and then restart it.</p>
<p>That&#8217;s it. You are done, after all these steps you can try<br />
<strong>rake db:migrate</strong><br />
Suppose if that doesn&#8217;t work then after 4th step, stop the mysql service and restart your system.</p>
<p>I welcome all of you to post your comments, feedbacks, queries</p>
<p>Cheers!!<br />
Puneet Pandey</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puneetitengineer.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puneetitengineer.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/puneetitengineer.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/puneetitengineer.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/puneetitengineer.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/puneetitengineer.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/puneetitengineer.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/puneetitengineer.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/puneetitengineer.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/puneetitengineer.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/puneetitengineer.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/puneetitengineer.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/puneetitengineer.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/puneetitengineer.wordpress.com/93/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=93&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puneetitengineer.wordpress.com/2009/09/24/rake-aborted-no-such-file-to-load-mysql/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9ffeee7fe7e3031d369d99673f06954?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Honey</media:title>
		</media:content>
	</item>
		<item>
		<title>Send Tweets from rails application</title>
		<link>http://puneetitengineer.wordpress.com/2009/08/12/send-tweets-from-rails-application/</link>
		<comments>http://puneetitengineer.wordpress.com/2009/08/12/send-tweets-from-rails-application/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 11:50:34 +0000</pubDate>
		<dc:creator>Puneet Pandey</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[how to send tweets from rails application]]></category>
		<category><![CDATA[rails tweet]]></category>
		<category><![CDATA[send tweets from your rails application]]></category>
		<category><![CDATA[twitter on rails]]></category>
		<category><![CDATA[twitter4r]]></category>

		<guid isPermaLink="false">http://puneetitengineer.wordpress.com/?p=88</guid>
		<description><![CDATA[Hey all, I hope this article will help you if you want to send tweets from your rails application. I have used couple of gems and plugins for that, will describe you those in this tutorial. AIM: We have a rails application which will allow twitter user to log-in. Once the user logged-in he/she can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=88&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hey all,</p>
<p>I hope this article will help you if you want to send tweets from your rails application. I have used couple of gems and plugins for that, will describe you those in this tutorial.</p>
<p>AIM: We have a rails application which will allow twitter user to log-in. Once the user logged-in he/she can send tweets from your rails application.</p>
<p>DEPENDENCIES: 1. geokit-rails [Plugin]<br />
2. ym4r-gm [Plugin]<br />
3. twitter4r [Gem]<br />
4. twitter-search [Gem]<br />
5. twitter-console [Gem]<br />
6. google-geocode [Gem] [Optional]</p>
<p>INSTALLATION:<br />
1. Install twitter4r (gem install twitter4r[for windows user], sudo gem install twitter4r[for linux users])<br />
2. Install twitter-search (sudo gem install dancroak-twitter-search -s http://gems.github.com)<br />
3. Install twitter-console *for linux users only<br />
[Follow this: http://www.fsckin.com/2008/03/31/twitter-clients-for-linux/]<br />
[and this: http://blog.guillermoamaral.com/2007/03/18/twitter-console-update/]<br />
4. Install google-geocode (sudo gem install google-geocode)<br />
5. Install goekit-rails<br />
5.1 ruby script/plugin install git://github.com/andre/geokit-rails.git<br />
5.2 Add this line to your environment.rb: config.gem &#8220;geokit&#8221;<br />
5.3 Tell Rails to install the gem: rake gems:install<br />
(for more details visit this link: http://github.com/andre/geokit-rails/tree/master)<br />
6. Install ym4r_gm (ruby script/plugin install svn://rubyforge.org/var/svn/ym4r/Plugins/GM/trunk/ym4r_gm)<br />
[if you get trouble in installation follow this: http://ym4r.rubyforge.org/]</p>
<p>So we have a base setup for our rails application. Now lets have some code.<br />
First of all lets create few models as well as migrations tables:<br />
1. ruby script/generate model Keyword<br />
2. ruby script/generate model Location<br />
3. ruby script/generate model Post<br />
4. ruby script/generate model User<br />
5. ruby script/generate model Techtwit<br />
6. ruby script/generate migration sessions</p>
<p>After creating all the above steps lets create some columns for our tables:<br />
1. for keywords: timestamps<br />
2. for locations: address:text, timestamps<br />
3. for posts: message: text, timestamps<br />
4. for users: username:string, password:string<br />
5. for techtwits: twitter_id:string, timestamps<br />
6. for sessions: session_id:string, data:text, timestamps<br />
6.1 add_index :sessions, :session_id<br />
6.2 add_index :sessions, :updated_at</p>
<p><a href="http://puneetpandey.com/2010/08/send-tweets-from-rails-application/" target="_blank">Follow this Tutorial </a> to finish-off this application.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puneetitengineer.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puneetitengineer.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/puneetitengineer.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/puneetitengineer.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/puneetitengineer.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/puneetitengineer.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/puneetitengineer.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/puneetitengineer.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/puneetitengineer.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/puneetitengineer.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/puneetitengineer.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/puneetitengineer.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/puneetitengineer.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/puneetitengineer.wordpress.com/88/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=88&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puneetitengineer.wordpress.com/2009/08/12/send-tweets-from-rails-application/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9ffeee7fe7e3031d369d99673f06954?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Honey</media:title>
		</media:content>
	</item>
		<item>
		<title>Minimise URL in Ruby</title>
		<link>http://puneetitengineer.wordpress.com/2009/07/27/minimise-url-in-ruby/</link>
		<comments>http://puneetitengineer.wordpress.com/2009/07/27/minimise-url-in-ruby/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 18:09:20 +0000</pubDate>
		<dc:creator>Puneet Pandey</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[bitly api for ruby on rails]]></category>
		<category><![CDATA[bitly for rails]]></category>
		<category><![CDATA[how to minimise url in ruby on rails]]></category>
		<category><![CDATA[minimise url in ruby]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ror]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://puneetitengineer.wordpress.com/?p=86</guid>
		<description><![CDATA[Does it looks odd?? You have so many websites which allows you to minimise your url like tinyurl, bit.ly etc etc list is endless, but what if you get some API of those to work with so you can minimise the url with your rails application or as a stand-alone ruby program?? Bit.ly comes with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=86&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Does it looks odd?? You have so many websites which allows you to minimise your url like tinyurl, bit.ly etc etc list is endless, but what if you get some API of those to work with so you can minimise the url with your rails application or as a stand-alone ruby program??</p>
<p>Bit.ly comes with that. It provides ruby programmers an interface by which they can minimise the url. Wondering How? see it in action..</p>
<p>I am creating a simple ruby program here, if you want you can use it in your application&#8230;</p>
<p>All you need is json and open-uri to finish it off.</p>
<p>require &#8216;open-uri&#8217;<br />
require &#8216;json&#8217;</p>
<p>code=&#8217;https://www.google.com/accounts/ServiceLogin?service=mail&amp;passive=true&amp;rm=false&amp;continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&amp;bsv=zpwhtygjntrz&amp;scc=1&amp;ltmpl=default&amp;ltmplcache=2&amp;hl=en&#8217;<br />
user=&#8217;YOUR USERNAME&#8217;<br />
apikey=&#8217;YOUR API KEY&#8217;<br />
version=&#8217;2.0.1&#8242;<br />
url = &#8220;http://api.bit.ly/shorten?version=#{version}&amp;longUrl=#{code}&amp;login=#{user}&amp;apiKey=#{apikey}&#8221;<br />
buffer = open(url, &#8220;UserAgent&#8221; =&gt; &#8220;Ruby-ExpandLink&#8221;).read<br />
result = JSON.parse(buffer)<br />
shorturl = result['results']['shortUrl']</p>
<p>That is it. Run this program in console/command prompt, where ever you want to see the output.</p>
<p>Post your queries, suggestions<br />
Puneet</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puneetitengineer.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puneetitengineer.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/puneetitengineer.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/puneetitengineer.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/puneetitengineer.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/puneetitengineer.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/puneetitengineer.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/puneetitengineer.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/puneetitengineer.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/puneetitengineer.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/puneetitengineer.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/puneetitengineer.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/puneetitengineer.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/puneetitengineer.wordpress.com/86/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=86&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puneetitengineer.wordpress.com/2009/07/27/minimise-url-in-ruby/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9ffeee7fe7e3031d369d99673f06954?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Honey</media:title>
		</media:content>
	</item>
		<item>
		<title>Bulk Upload with Rubyzip</title>
		<link>http://puneetitengineer.wordpress.com/2009/07/27/bulk-upload-with-rubyzip/</link>
		<comments>http://puneetitengineer.wordpress.com/2009/07/27/bulk-upload-with-rubyzip/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 17:49:27 +0000</pubDate>
		<dc:creator>Puneet Pandey</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Ajax file upload with rails]]></category>
		<category><![CDATA[Bulk upload with ruby on rails]]></category>
		<category><![CDATA[extract zip files with ruby on rails]]></category>
		<category><![CDATA[multiple upload with ruby on rails]]></category>
		<category><![CDATA[rubyzip]]></category>

		<guid isPermaLink="false">http://puneetitengineer.wordpress.com/?p=83</guid>
		<description><![CDATA[Hi guys, Its been a long time since I posted any article. This time I come up with Interesting Tutorial which is Bulk Upload. Normally in most of the sites we have seen that there is a file upload field where we can upload a zip file and it will extract automatically. Now the Point [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=83&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi guys,</p>
<p>Its been a long time since I posted any article. This time I come up with Interesting Tutorial which is Bulk Upload. Normally in most of the sites we have seen that there is a file upload field where we can upload a zip file and it will extract automatically.</p>
<p>Now the Point is How it can be done is Ruby on Rails? The answer is very simple, all we need are two gems + few lines of code. Wondering How?? See this in action&#8230;</p>
<p>Install two gems first:</p>
<p>for Linux Users:</p>
<p>1. sudo gem install rubyzip</p>
<p>2. sudo gem install fastercsv</p>
<p>for windows users: remove sudo and install above gems.</p>
<p>now open up your rhtml page and write down the following code:</p>
<pre>&lt;% form_for :file_upload,:url =&gt; {:controller=&gt;'bulkupload',:action=&gt;'upload_file'}, :html =&gt; { :multipart =&gt; true, :target =&gt; "frame", :id =&gt; "file_upload" } do |f| %&gt;
&lt;input type="file" name="file_upload_product[file_name]"/&gt;
&lt;input type="submit" value="Upload"/&gt;
&lt;%end%&gt;

Now Open up your bulkupload controller and create method upload_file in that

require 'faster_csv'
require 'fileutils'
class BulkuploadProductController &lt; ApplicationController
  def bulk_upload
    begin
     @file=FileUpload.new
     @file.file_name=params[:file_upload_product]['file_name']
     if @file.save
      responds_to_parent do
       render :update do |page|
        page &lt;&lt; "$('file_uploaded_id').value="+@file.id.to_s
        page.replace_html 'upload_message',"&lt;span class='heading4'&gt;File has been moved to server. Please click submit to upload.&lt;/span&gt;"
       end
      end
     else
      responds_to_parent do
       render :update do |page|
        page.replace_html 'upload_message',"&lt;span class='table_commands_row'&gt;Please Upload File&lt;/span&gt;"
       end
      end
     end
     rescue Exception=&gt;e
      puts "ERROR :: bulkupload_products :: upload_file :: #{e.to_s}"
      responds_to_parent do
       render :update do |page|
        page.replace_html 'upload_message',"&lt;span class='table_commands_row'&gt;Some internal Error has occurred&lt;/span&gt;"
       end
      end
    end
  end
end

Let me know if you have any doubts</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puneetitengineer.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puneetitengineer.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/puneetitengineer.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/puneetitengineer.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/puneetitengineer.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/puneetitengineer.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/puneetitengineer.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/puneetitengineer.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/puneetitengineer.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/puneetitengineer.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/puneetitengineer.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/puneetitengineer.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/puneetitengineer.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/puneetitengineer.wordpress.com/83/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=83&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puneetitengineer.wordpress.com/2009/07/27/bulk-upload-with-rubyzip/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9ffeee7fe7e3031d369d99673f06954?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Honey</media:title>
		</media:content>
	</item>
		<item>
		<title>Fetch contacts from Facebook using Ruby on Rails</title>
		<link>http://puneetitengineer.wordpress.com/2009/03/13/fetch-contacts-from-facebook-using-ruby-on-rails/</link>
		<comments>http://puneetitengineer.wordpress.com/2009/03/13/fetch-contacts-from-facebook-using-ruby-on-rails/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 05:17:10 +0000</pubDate>
		<dc:creator>Puneet Pandey</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Add Facebook friends using ruby on rails]]></category>
		<category><![CDATA[Fetch facebook friends using rails]]></category>
		<category><![CDATA[How to fetch contacts from facebook]]></category>

		<guid isPermaLink="false">http://puneetitengineer.wordpress.com/?p=75</guid>
		<description><![CDATA[Volaaaa&#8230;. Finally I&#8217;ve got the way, how should I fetch contacts from facebook.. I hope everyone is looking for it.. Let me show you how would I do that. Note: You can&#8217;t get your contacts email addresses using this post. Mandatory Data: [1] facebooker plugin [2] Facebook developer application Now how to do it let&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=75&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Volaaaa&#8230;. Finally I&#8217;ve got the way, how should I fetch contacts from facebook.. I hope everyone is looking for it..</p>
<p>Let me show you how would I do that.<br />
Note: You can&#8217;t get your contacts email addresses using this post.<br />
Mandatory Data:<br />
[1] facebooker plugin<br />
[2] Facebook developer application</p>
<p>Now how to do it let&#8217;s see:<br />
Install facebooker plugin from <a href="http://facebooker.rubyforge.org/">Here</a> into your rails application.<br />
If you are done with that go to <a href="http://www.facebook.com/">Facebook</a>, if you have your account there sign-in and then search for developer application, add it if you haven&#8217;t added before. Below is the screenshot how you developer application looks like:</p>
<p><a href="http://puneetitengineer.files.wordpress.com/2009/03/facebook_developer.jpg"><img class="aligncenter size-full wp-image-76" title="facebook_developer" src="http://puneetitengineer.files.wordpress.com/2009/03/facebook_developer.jpg?w=500&#038;h=194" alt="facebook_developer" width="500" height="194" /></a></p>
<p>Now here you can see a button &#8220;Set up New Application&#8221; click on that It will led you to a new application page like this:</p>
<p><a href="http://puneetitengineer.files.wordpress.com/2009/03/new_fb_app.jpg"><img class="aligncenter size-full wp-image-77" title="new_fb_app" src="http://puneetitengineer.files.wordpress.com/2009/03/new_fb_app.jpg?w=500&#038;h=194" alt="new_fb_app" width="500" height="194" /></a></p>
<p>Give the name of your new application click on Agree and then &#8220;Save Changes&#8221;, Once your new application is created click on &#8220;Edit Settings&#8221; link on the right side of the center div.</p>
<p>It will drop you to a new page click on &#8220;Canvas&#8221; tab and give your &#8220;Callback URL&#8221; and &#8220;Canvas Page URL&#8221;.<br />
NOTE: make sure those two fields are not blank and properly accepted by the facebook.</p>
<p>Now &#8220;back to My Applications&#8221;, you will find that you have following things:<br />
[1] API Key<br />
[2] Application Secret<br />
[3] Callback URL<br />
[4] Canvas URL</p>
<p>Now back into your rails application, after installing the plugin, you will find that a file facebooker.yml has been created for you in the config folder just open that and put all the 4 things inside that wherever it is needed.</p>
<p>Awesome Man!!!!! you are almost done.. just couple of steps short to see it in action</p>
<p>Create a controller for your rails application in my case it is:<br />
ruby script/generate controller GettingStarted<br />
open this file and paste the below lines:</p>
<p>class GettingStartedController &lt; ApplicationController<br />
ensure_authenticated_to_facebook</p>
<p>def index<br />
@user = session[:facebook_session].user<br />
@frnd=@user.friends!(:name, :interests, :status)<br />
end<br />
end</p>
<p>Now open up index.html.erb and paste the below code:<br />
&lt;input type=&#8221;textarea&#8221; name=&#8221;show_code&#8221; value=&#8221;</p>
<p>Disecting FaceBook With</p>
<p>body{padding:0px;margin:0px;font-family:verdana,Trebuchet MS; font-size:12px; background-color:#eee;}<br />
p.rowA {background-color: #C6DB7C; color:#000000;width:400px; }<br />
p.rowB {background-color: #457AA0;width:400px; }<br />
p{margin:0px; padding:10px;}<br />
#left{width:40%;border:1px solid #eee;float:left; padding:10px;}<br />
#right{width:50%; border:1px solid #eee; float:right; padding:10px;color:white;}</p>
<h3>Hey we got you !!</h3>
<div id="right-pane">&lt;img src=&#8221;" /&gt;</p>
<p><strong> </strong><br />
<strong> </strong></p>
<div id="right">
<h4 style="color:#000000;">These are the people, you talking with?</h4>
<p>&lt;p class=&#8221;"&gt; &lt;input type=&#8221;checkbox&#8221; name=&#8221;facebook_friends[]&#8221; id=&#8221;facebook_friends_&#8221; value=&#8221;" /&gt; &lt;%= &#8220;<strong>Friend:</strong> #{friend.name}<br />
<strong> #{hash}</strong><br />
<strong>Interests:</strong> #{friend.interests}</p>
<p>&#8221;  %&gt;</p></div>
</div>
<p>&#8221; rows=&#8221;10&#8243; cols=&#8221;20&#8243;&gt;</p>
<p>create another file manually index.fbml.erb and paste the below code:</p>
<p>That&#8217;s it.. everything is finished.. start your server</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puneetitengineer.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puneetitengineer.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/puneetitengineer.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/puneetitengineer.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/puneetitengineer.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/puneetitengineer.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/puneetitengineer.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/puneetitengineer.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/puneetitengineer.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/puneetitengineer.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/puneetitengineer.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/puneetitengineer.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/puneetitengineer.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/puneetitengineer.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puneetitengineer.wordpress.com&amp;blog=1929229&amp;post=75&amp;subd=puneetitengineer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puneetitengineer.wordpress.com/2009/03/13/fetch-contacts-from-facebook-using-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c9ffeee7fe7e3031d369d99673f06954?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Honey</media:title>
		</media:content>

		<media:content url="http://puneetitengineer.files.wordpress.com/2009/03/facebook_developer.jpg" medium="image">
			<media:title type="html">facebook_developer</media:title>
		</media:content>

		<media:content url="http://puneetitengineer.files.wordpress.com/2009/03/new_fb_app.jpg" medium="image">
			<media:title type="html">new_fb_app</media:title>
		</media:content>
	</item>
	</channel>
</rss>
