<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="http://feeds.feedburner.com/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><!-- generator="wordpress/2.0.5" --><rss 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/" version="2.0">

<channel>
	<title>Web On Rails</title>
	<link>http://webonrails.com</link>
	<description>Exploring RubyOnRails</description>
	<pubDate>Wed, 23 Apr 2008 18:20:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/WebOnRails" type="application/rss+xml" /><item>
		<title>Git Error: trailing whitespace, indent SP followed by a TAB, unresolved merge conflict</title>
		<link>http://webonrails.com/2008/04/23/git-error-trailing-whitespace-indent-sp-followed-by-a-tab-unresolved-merge-conflict/</link>
		<comments>http://webonrails.com/2008/04/23/git-error-trailing-whitespace-indent-sp-followed-by-a-tab-unresolved-merge-conflict/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 18:19:34 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
		
		<category>Rails</category>

		<category>RubyonRails</category>

		<category>Tools</category>

		<category>Git</category>

		<category>VCS</category>

		<category>SCM</category>

		<category>pre-commit</category>

		<guid isPermaLink="false">http://webonrails.com/2008/04/23/git-error-trailing-whitespace-indent-sp-followed-by-a-tab-unresolved-merge-conflict/</guid>
		<description><![CDATA[I have been using Git from last few days, and faced following errors while committing:
1) Trailing whitespace
2) Indent SP followed by a TAB
3) Unresolved merge conflict
The first error &#8220;Trailing whitespace&#8221; is because of carriage-return/line-feed(windows style line feed/end). To resolve this problem comment following lines(58-60) in .git/hooks/pre-commit file:

  if (/\s$/) {
    bad_line("trailing [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using <a href="http://git.or.cz/" target ="_blank">Git</a> from last few days, and faced following errors while committing:</p>
<p>1) Trailing whitespace<br />
2) Indent SP followed by a TAB<br />
3) Unresolved merge conflict</p>
<p>The first error <strong>&#8220;Trailing whitespace&#8221;</strong> is because of carriage-return/line-feed(windows style line feed/end). To resolve this problem comment following <strong>lines(58-60) in .git/hooks/pre-commit file</strong>:</p>
<textarea name="code" class="c" cols="50" rows="10">
  if (/\s$/) {
    bad_line("trailing whitespace", $_);
 }
</textarea>
<p>The second one <strong>&#8220;Indent SP followed by a TAB&#8221;</strong> is because of leading spaces/tabs. To resolve this problem comment following <strong>lines(61-63) in .git/hooks/pre-commit file</strong>:</p>
<textarea name="code" class="c" cols="50" rows="10">
  if (/^\s*   /) {
    bad_line("indent SP followed by a TAB", $_);
  }
</textarea>
<p>The third one <strong>&#8220;Unresolved merge conflict&#8221;</strong> is because of seven or more successive  occurrence of = or < or > characters. Major chances of having seven = character in README or doc files. To resolve this problem replace following <strong>line(64) in .git/hooks/pre-commit file</strong>:</p>
<textarea name="code" class="c" cols="50" rows="10">
  if (/^(?:[<>=]){7}/) {
</textarea>
<p>by </p>
<textarea name="code" class="c" cols="50" rows="10">
  if (/^(?:[<>=]){7}$/) {
</textarea>
<p>These tricks worked for me, I hope it could help you.
</p>
]]></content:encoded>
			<wfw:commentRss>http://webonrails.com/2008/04/23/git-error-trailing-whitespace-indent-sp-followed-by-a-tab-unresolved-merge-conflict/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rails Plugin Annotate Models For Spec And Spec Fixtures</title>
		<link>http://webonrails.com/2008/04/23/rails-plugin-annotate-models-for-spec-and-spec-fixtures/</link>
		<comments>http://webonrails.com/2008/04/23/rails-plugin-annotate-models-for-spec-and-spec-fixtures/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 11:18:14 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
		
		<category>Rails</category>

		<category>Rails Plugins</category>

		<category>Ruby</category>

		<category>RubyonRails</category>

		<category>Subversion</category>

		<category>Tools</category>

		<category>Git</category>

		<category>VCS</category>

		<category>svn</category>

		<category>annotate_models</category>

		<category>patch</category>

		<guid isPermaLink="false">http://webonrails.com/2008/04/23/rails-plugin-annotate-models-for-spec-and-spec-fixtures/</guid>
		<description><![CDATA[I have been using &#8220;Annotate Models&#8221; rails plugin written by Dave Thomas since I found it around one and half year ago. It really helps while writing fixtures. But if you use RSpec you might miss schema info at the top of your rspec fixture file as I do. So, today I modify the plugin [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using &#8220;Annotate Models&#8221; rails plugin written by Dave Thomas since I found it around one and half year ago. It really helps while writing fixtures. But if you use RSpec you might miss schema info at the top of your rspec fixture file as I do. So, today I modify the plugin file so that it prepends schema info to spec file and fixture file. Below are the links of patch file:</p>
<p><a href="http://webonrails.com/wp-content/plugins/wp-downloadMonitor/download.php?id=9" title="Version 0.1 downloaded 142 times" >svn patch to add schema info to spec file and spec fixture file</a><br />
<a href="http://webonrails.com/wp-content/plugins/wp-downloadMonitor/download.php?id=10" title="Version 0.1 downloaded 132 times" >git patch to add schema info to spec file and spec fixture file</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://webonrails.com/2008/04/23/rails-plugin-annotate-models-for-spec-and-spec-fixtures/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Git - Fast Version Control System</title>
		<link>http://webonrails.com/2008/02/15/git-fast-version-control-system/</link>
		<comments>http://webonrails.com/2008/02/15/git-fast-version-control-system/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 19:11:01 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
		
		<category>Rails</category>

		<category>Subversion</category>

		<category>Technology</category>

		<category>Tools</category>

		<category>Git</category>

		<category>VCS</category>

		<category>svn</category>

		<category>SCM</category>

		<guid isPermaLink="false">http://webonrails.com/2008/02/15/git-fast-version-control-system/</guid>
		<description><![CDATA[Git is getting popular in Rails community these days, as there were being many changes in rails to support Git.
Git is a open sourse fast version controller system. It was originally designed by Linus Torvalds to handle large projects. It was inspired by Monotone &#038; BitKeeper. It is a distributed version controlling system. It gives [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://git.or.cz/">Git</a> is getting popular in Rails community these days, as there were being many <a href="http://dev.rubyonrails.org/changeset/8772">changes</a> in rails to support Git.<br />
Git is a open sourse fast version controller system. It was originally designed by Linus Torvalds to handle large projects. It was inspired by Monotone &#038; BitKeeper. It is a distributed version controlling system. It gives you ability to commit, traverse into history while being offline. Actually every working copy of Git is a full-fledged repository. It has no central server like <a href="http://subversion.tigris.org/">SVN</a>. One can share his working-copy/repository by using various protocols like ssh, http, ftp etc. One thing I like about Git over SVN is that the size of Git&#8217;s repository, which is smaller compared to SVN.</p>
<p>I gave an introductory presentation in <a href="http://vinsol.com/">VinSol</a>. I am sharing it with you, this is not very explanatory as I focused on speech more. Please share your views.</p>
<div style="width:425px;text-align:left" id="__ss_354888"><object style="margin:0px" width="425" height="355">
<param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=git1-1208284093507575-8"/>
<param name="allowFullScreen" value="true"/>
<param name="allowScriptAccess" value="always"/><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=git1-1208284093507575-8" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;"><a href="http://www.slideshare.net/?src=embed"><img src="http://static.slideshare.net/swf/logo_embd.png" style="border:0px none;margin-bottom:-5px" alt="SlideShare"/></a> | <a href="http://www.slideshare.net/bansalakhil/git-fast-version-control-system-354888?src=embed" title="View 'Git- Fast version control system' on SlideShare">View</a> | <a href="http://www.slideshare.net/upload?src=embed">Upload your own</a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://webonrails.com/2008/02/15/git-fast-version-control-system/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Migration: Adding/Removing columns are now much easier</title>
		<link>http://webonrails.com/2008/01/23/migration_adding_removing_columns_are_now_much_easier/</link>
		<comments>http://webonrails.com/2008/01/23/migration_adding_removing_columns_are_now_much_easier/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 17:24:54 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
		
		<category>Rails</category>

		<category>Ruby</category>

		<category>RubyonRails</category>

		<category>Technology</category>

		<category>Web Development</category>

		<category>migration</category>

		<guid isPermaLink="false">http://webonrails.com/2008/01/23/migration_adding_removing_columns_are_now_much_easier/</guid>
		<description><![CDATA[You may have noticed by now, that in Rails 2.0 changeset 7422, you can specify columns you want to add/remove in your migration by passing attribute:type pairs to the migration generator. 
For example, lets assume that we need to add a column &#8216;role&#8217; in users table(User model). In this case generate a migration like:

script/generate migration [...]]]></description>
			<content:encoded><![CDATA[<p>You may have noticed by now, that in Rails 2.0 <a href="http://dev.rubyonrails.org/changeset/7422">changeset 7422</a>, you can specify columns you want to add/remove in your migration by passing <strong>attribute:type</strong> pairs to the migration generator. </p>
<p>For example, lets assume that we need to add a column &#8216;role&#8217; in users table(User model). In this case generate a migration like:</p>
<textarea name="code" class="ruby" cols="50" rows="10">
script/generate migration AddRoleToUser role:string
</textarea>
<p>Output:</p>
<textarea name="code" class="ruby" cols="50" rows="10">
class AddRoleToUser < ActiveRecord::Migration
  def self.up
    add_column :users, :role, :string
  end

  def self.down
    remove_column :users, :role
  end
end
</textarea>
<p>Here <strong>Add</strong>Role<strong><em>To</em></strong><strong>User</strong> plays the main role. &#8216;Add&#8217; specifies the we want to add column(s) and &#8216;User&#8217; separated by &#8216;To&#8217; specifies the table.</p>
<p>Similarly, if we need to remove a column &#8216;role&#8217; :</p>
<textarea name="code" class="ruby" cols="50" rows="10">
 script/generate migration RemoveRoleFromUser role:string
</textarea>
<p>Output:</p>
<textarea name="code" class="ruby" cols="50" rows="10">
class RemoveRoleFromUser < ActiveRecord::Migration
  def self.up
    remove_column :users, :role
  end

  def self.down
    add_column :users, :role, :string
  end
end
</textarea>
<p>Here <strong>Remove</strong>Role<strong><em>From</em></strong><strong>User</strong> plays the main role. &#8216;Remove&#8217; specifies the we want to remove column(s) and &#8216;User&#8217; separated by &#8216;From&#8217; specifies the table.</p>
<p>Isn&#8217;t it cool?
</p>
]]></content:encoded>
			<wfw:commentRss>http://webonrails.com/2008/01/23/migration_adding_removing_columns_are_now_much_easier/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ajax based online ruby API documentation</title>
		<link>http://webonrails.com/2008/01/14/ajax-based-online-ruby-api-documentation/</link>
		<comments>http://webonrails.com/2008/01/14/ajax-based-online-ruby-api-documentation/#comments</comments>
		<pubDate>Mon, 14 Jan 2008 18:10:07 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
		
		<category>Ajax</category>

		<category>Ruby</category>

		<guid isPermaLink="false">http://webonrails.com/2008/01/14/ajax-based-online-ruby-api-documentation/</guid>
		<description><![CDATA[http://www.rubybrain.com/

]]></description>
			<content:encoded><![CDATA[<p>http://www.rubybrain.com/
</p>
]]></content:encoded>
			<wfw:commentRss>http://webonrails.com/2008/01/14/ajax-based-online-ruby-api-documentation/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ruby Script for SVN commit notification with log message, list of updated files and readable colored SVN Diff</title>
		<link>http://webonrails.com/2008/01/14/ruby-script-for-svn-commit-notification-with-log-message-list-of-updated-files-and-readable-colored-svn-diff/</link>
		<comments>http://webonrails.com/2008/01/14/ruby-script-for-svn-commit-notification-with-log-message-list-of-updated-files-and-readable-colored-svn-diff/#comments</comments>
		<pubDate>Mon, 14 Jan 2008 14:17:16 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
		
		<category>Rails</category>

		<category>Ruby</category>

		<category>RubyonRails</category>

		<category>Subversion</category>

		<category>Technology</category>

		<category>Web Development</category>

		<category>Tools</category>

		<category>notification</category>

		<guid isPermaLink="false">http://webonrails.com/2008/01/14/ruby-script-for-svn-commit-notification-with-log-message-list-of-updated-files-and-readable-colored-svn-diff/</guid>
		<description><![CDATA[Some days ago I wrote a post about &#8220;SVN commit notification&#8221; which uses a perl script for sending commit notification with svn diff by mail. In this mail you can find svn diff from the last committed revision. I used to love this mail, soon I realized that it is a bit ugly and difficult [...]]]></description>
			<content:encoded><![CDATA[<p>Some days ago I wrote a post about &#8220;<a href="http://webonrails.com/2007/07/12/get-svn-commit-notification-right-into-your-inbox-by-using-svn-hook-post-commit/">SVN commit notification</a>&#8221; which uses a perl script for sending commit notification with svn diff by mail. In this mail you can find svn diff from the last committed revision. I used to love this mail, soon I realized that it is a bit ugly and difficult to read. Also there were some important information missing.  Like the name of user committing the code, the log message etc&#8230; </p>
<p>And then I started writing my own ruby script for same purpose but with some addition and modification. <a href="http://webonrails.com/wp-content/plugins/wp-downloadMonitor/download.php?id=8" title="Version 0.2 downloaded 355 times" >Commit notification script</a> is that script, you can download and configure it with your SVN post commit hook as follows.</p>
<p>Add following line at the bottom of your post-commit file:</p>
<textarea name="code" class="ruby" cols="50" rows="10">
/usr/bin/ruby /var/www/repositories/project/hooks/commit-email.rb "$1"  "$2"
</textarea>
<p>* Please remember to change the path of you commit-email ruby script.</p>
<p>Now open commit-email ruby file and modify the following section according to your requirement:</p>
<textarea name="code" class="ruby" cols="50" rows="10">
# You can edit below

# Subject prefix
sub = "[test_project@vinsol]"  # A project 'test_project' is maitained at vinsol

#list of users who will recieve commit notification
recipients = ["bansalakhil30.10@gmail.com", "akhil@vinsol.com"]

# email which will appear in from email field
from_user = "svn-notify@somedomain.com"

# your smtp settings here
ActionMailer::Base.smtp_settings = { :address => 'localhost', :port => 25, :domain => 'domain.com'}

# Do not edit below this line
</textarea>
<p>You are done with that, now onwards whenever someone commits the code, you&#8217;ll get the commit notification mail like:</p>
<p><a class="imagelink" href="http://webonrails.com/wp-content/uploads/2008/01/commit-email-preview.png" title="Commit Email Preview"><img id="image104"  width = 100% src="http://webonrails.com/wp-content/uploads/2008/01/commit-email-preview.png" alt="Commit Email Preview" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://webonrails.com/2008/01/14/ruby-script-for-svn-commit-notification-with-log-message-list-of-updated-files-and-readable-colored-svn-diff/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Presented at BarCampDelhi3</title>
		<link>http://webonrails.com/2007/12/10/presented-in-barcampdelhi3/</link>
		<comments>http://webonrails.com/2007/12/10/presented-in-barcampdelhi3/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 07:57:33 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
		
		<category>Rails</category>

		<category>RubyonRails</category>

		<category>Barcamp</category>

		<category>hosting</category>

		<category>deployment</category>

		<category>Delhi</category>

		<category>Event</category>

		<category>EC2</category>

		<guid isPermaLink="false">http://webonrails.com/2007/12/10/presented-in-barcampdelhi3/</guid>
		<description><![CDATA[Yesterday, I attended third barcamp in delhi. I presented a session &#8220;Deploying rails application in EC2&#8243;.  It was an amazing experience. We talked about EC2 and I had given a demo &#8220;How to deploy rails application on EC2&#8243;.
I personally didn&#8217;t like some sessions. There were people from some company and after every 2 mins [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I attended<a href="http://www.barcamp.org/BarCampDelhi3"> third barcamp in delhi</a>. I presented a session &#8220;Deploying rails application in EC2&#8243;.  It was an amazing experience. We talked about EC2 and I had given a demo &#8220;How to deploy rails application on EC2&#8243;.</p>
<p>I personally didn&#8217;t like some sessions. There were people from some company and after every 2 mins they were saying &#8220;we are the best&#8221;. I think this should not happen in barcamp. As far as I know about barcamp, it is for sharing your experiences, talking about new technology, but not for promoting your company.</p>
<p>I think that, at BarCamp there should be sessions on new things, not on the things that are popular and have similar other services.</p>
<p>There was a very good session by  Jinesh Varia on Amazon Cloud Computing. He included Amazon&#8217;s simple storage system, and  Amazon&#8217;s cloud computing(Ec2) in his presentation. He also helped me in answering people while the demo. He gave me a hint that very soon there will a news from Amazon that will surprise us. </p>
<p>I have uploaded my presentation slides on Slideshare.net:</p>
<div style="width:425px;text-align:left" id="__ss_197972"><object style="margin:0px" width="425" height="355">
<param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=deploying-rails-app-on-ec2-1197272291134652-3"/>
<param name="allowFullScreen" value="true"/>
<param name="allowScriptAccess" value="always"/><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=deploying-rails-app-on-ec2-1197272291134652-3" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;"><a href="http://www.slideshare.net/?src=embed"><img src="http://static.slideshare.net/swf/logo_embd.png" style="border:0px none;margin-bottom:-5px" alt="SlideShare"/></a> | <a href="http://www.slideshare.net/bansalakhil/deploying-rails-app-on-ec2" title="View 'Deploying Rails App On Ec2' on SlideShare">View</a> | <a href="http://www.slideshare.net/upload">Upload your own</a></div>
</div>
<p>Thanks to <a href="http://impetus.com">Impetus</a> Noida for Hosting Barcamp for second time and <a href="http://www.opera.com/">Opera</a> for Beer.
</p>
]]></content:encoded>
			<wfw:commentRss>http://webonrails.com/2007/12/10/presented-in-barcampdelhi3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Third Delhi BarCamp</title>
		<link>http://webonrails.com/2007/11/21/third-delhi-barcamp/</link>
		<comments>http://webonrails.com/2007/11/21/third-delhi-barcamp/#comments</comments>
		<pubDate>Wed, 21 Nov 2007 08:27:04 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
		
		<category>Rails</category>

		<category>Barcamp</category>

		<category>Delhi</category>

		<category>Event</category>

		<guid isPermaLink="false">http://webonrails.com/2007/11/21/third-delhi-barcamp/</guid>
		<description><![CDATA[I have a great news for you guys. We are planning Third BarCamp on Saturday, 8 December 2007, in Delhi.
Venue is not finalize yet, We have some options and shortlisting the final one.
We are also waiting for someone to take the sponsorship ;-)
Some people have proposed their sessions, I am proposing two with Manik. List [...]]]></description>
			<content:encoded><![CDATA[<p>I have a great news for you guys. We are planning Third BarCamp on Saturday, 8 December 2007, in Delhi.<br />
Venue is not finalize yet, We have some options and shortlisting the final one.<br />
We are also waiting for someone to take the sponsorship ;-)<br />
Some people have proposed their sessions, I am proposing two with <a href="http://fromdelhi.com">Manik</a>. List of sessions(as of now):</p>
<ul>
<strong>    * Deploying Rails app on EC2 (Manik Juneja and Akhil Bansal)<br />
    * Comparison of various Rails Hosting services. (Manik Juneja and Akhil Bansal)<br />
</strong>    * Using Jmeter for Stress Testing your webapp<br />
    * Desi Social Networking - Visual web ( Swagat Sen )<br />
    * Everyday Productivity with Windows Live Tools (Abhishek Kant)<br />
    * Gurugeeks - A call out for Web Geeks (Navjot Pawera)<br />
    * Web Semantics and Accessibility (Navjot Pawera)
</ul>
<p>If you are planning to Attend/Present something you or want to help us in any way  please visit  <a href="http://barcamp.org/BarCampDelhi3">http://barcamp.org/BarCampDelhi3</a> and add you name in appropriate section.</p>
<p>So see you in the camp ;-)
</p>
]]></content:encoded>
			<wfw:commentRss>http://webonrails.com/2007/11/21/third-delhi-barcamp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Two best online API/Rails API</title>
		<link>http://webonrails.com/2007/11/05/two-best-online-api-rails-api/</link>
		<comments>http://webonrails.com/2007/11/05/two-best-online-api-rails-api/#comments</comments>
		<pubDate>Mon, 05 Nov 2007 08:08:17 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
		
		<category>Ajax</category>

		<category>Rails</category>

		<category>Ruby</category>

		<category>RubyonRails</category>

		<category>API</category>

		<guid isPermaLink="false">http://webonrails.com/2007/11/05/two-best-online-apirails-api/</guid>
		<description><![CDATA[Today I found two best API sites. One is http://www.gotapi.com.
This site provides APIs of almost all languages.
The other API site which is only focused on Rails is http://www.railsbrain.com/. I like this most. You can also download this API. It is AJAX based fast, useful.

]]></description>
			<content:encoded><![CDATA[<p>Today I found two best API sites. One is <a href="http://www.gotapi.com">http://www.gotapi.com</a>.<br />
This site provides APIs of almost all languages.</p>
<p>The other API site which is only focused on Rails is <a href="http://www.railsbrain.com/">http://www.railsbrain.com/</a>. I like this most. You can also download this API. It is AJAX based fast, useful.
</p>
]]></content:encoded>
			<wfw:commentRss>http://webonrails.com/2007/11/05/two-best-online-api-rails-api/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Single Table Inheritance validates_uniqueness_of Problem</title>
		<link>http://webonrails.com/2007/10/26/single-table-inheritance-validates_uniqueness_of-problem/</link>
		<comments>http://webonrails.com/2007/10/26/single-table-inheritance-validates_uniqueness_of-problem/#comments</comments>
		<pubDate>Fri, 26 Oct 2007 07:45:02 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
		
		<category>Rails</category>

		<category>Ruby</category>

		<category>RubyonRails</category>

		<category>Technology</category>

		<category>Web Development</category>

		<guid isPermaLink="false">http://webonrails.com/2007/10/26/single-table-inheritance-validates_uniqueness_of-problem/</guid>
		<description><![CDATA[Consider a case of STI where:

class User < ActiveRecord::Base
  validates_uniqueness_of :name
end

class Customer < User

end

class Manager < User

end

Now try following at console:

User.create(:name => "Akhil Bansal")
Manager.create(:name => "Akhil Bansal")
Customer.create(:name => "Akhil Bansal")

This will let you create three records in users table with same name, validates_uniqueness_of written in User class has no effect on it. validates_uniqueness_of automatically [...]]]></description>
			<content:encoded><![CDATA[<p>Consider a case of STI where:</p>
<textarea name="code" class="ruby" cols="50" rows="10">
class User < ActiveRecord::Base
  validates_uniqueness_of :name
end

class Customer < User

end

class Manager < User

end
</textarea>
<p>Now try following at console:</p>
<textarea name="code" class="ruby" cols="50" rows="10">
User.create(:name => "Akhil Bansal")
Manager.create(:name => "Akhil Bansal")
Customer.create(:name => "Akhil Bansal")
</textarea>
<p>This will let you create three records in users table with same name, validates_uniqueness_of written in User class has no effect on it. validates_uniqueness_of automatically scoped with class names, that means it will not let you create two managers with same name or two customers with same name  or two users with same name. </p>
<p>If you want uniqueness of an attribute in overall table, put the following code in some file in your lib dir and require that file in environment:</p>
<textarea name="code" class="ruby" cols="50" rows="10">
module ActiveRecord
  module Validations
    module ClassMethods
      # Intended for use with STI tables, helps ignore the type field
      def validates_overall_uniqueness_of(*attr_names)
        configuration = { :message => "has already been taken" }
        configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash)
        validates_each(attr_names, configuration) do |record, attr_name, value|
          records = self.find(:all, :conditions=> ["#{attr_name} = ?", value])
          record.errors.add(attr_name, configuration[:message]) if records.size > 0 and records[0].id != record.id
        end
      end
    end
  end
end
</textarea>
<p>And then use validates_overall_uniqueness_of instead of validates_uniqueness_of.
</p>
]]></content:encoded>
			<wfw:commentRss>http://webonrails.com/2007/10/26/single-table-inheritance-validates_uniqueness_of-problem/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Running Rails Application on https with pound</title>
		<link>http://webonrails.com/2007/09/13/running-rails-application-on-https-with-pound/</link>
		<comments>http://webonrails.com/2007/09/13/running-rails-application-on-https-with-pound/#comments</comments>
		<pubDate>Thu, 13 Sep 2007 13:58:56 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
		
		<category>Rails</category>

		<category>RubyonRails</category>

		<category>Technology</category>

		<category>hosting</category>

		<category>pound</category>

		<category>mongrel_cluster</category>

		<category>deployment</category>

		<category>https</category>

		<guid isPermaLink="false">http://webonrails.com/2007/09/13/running-rails-application-on-https-with-pound/</guid>
		<description><![CDATA[Hours ago, I posted about, &#8220;How to deploy rails application with pound as a Balancer&#8221;.
Lets run rails application on https with pound. For that your machine should have:
* Pound installed with ssl support
* Pound and mongrels running
Now, First of all we need a ssl certificate, that can be generate by issuing &#8220;openssl req -x509 -newkey [...]]]></description>
			<content:encoded><![CDATA[<p>Hours ago, I posted about, <a href="http://webonrails.com/2007/09/13/deploying-rails-application-with-pound-as-a-balancer/" target = "_blank">&#8220;How to deploy rails application with pound as a Balancer&#8221;</a>.</p>
<p>Lets run rails application on https with pound. For that your machine should have:</p>
<p>* Pound installed with ssl support<br />
* Pound and mongrels running</p>
<p>Now, First of all we need a ssl certificate, that can be generate by issuing <strong>&#8220;openssl req -x509 -newkey rsa:1024 -keyout mydomain.pem  -out mydomain.pem -days 365 -nodes&#8221;</strong> . Give all the information it asks. Now copy mydomain.pem to /etc/pound/ directory(I am assuming that your pound.cfg file resides in /etc/pound/). Now put the following code in pound configuration file(/etc/pound/pound.cfg):</p>
<textarea name="code" class="c++" cols="50" rows="10">
ListenHTTPS
  Address 0.0.0.0
  Port    443
  Cert    "/etc/pound/mydomain.pem" 
  # pass along https hint
  AddHeader "X-Forwarded-Proto: https" 
  HeadRemove "X-Forwarded-Proto" 

Service
    URL "/(images|stylesheets|javascripts)/"
    BackEnd
        Address 127.0.0.1
        Port    8080
    End
    Session
        Type    BASIC
        TTL     300
    End

End

  Service
    BackEnd
      Address 127.0.0.1
      Port    8000
    End
    BackEnd
      Address 127.0.0.1
      Port    8001
    End
    BackEnd
      Address 127.0.0.1
      Port    8002
    End
  End
End
</textarea>
<p>I am assuming that your mongrels are running at ports 8000, 8001, 8002, apache running at 8080 and pound is listening ports 443 &#038; 80.<br />
Restart pound, and you are done. With this configuration all requests for dynamic content at port 443(https) will get redirected to mongrels and requests for static content will get redirected to apache.</p>
<p>You may want to check if the request is https or not before serving the content. That can be done by adding a before_filter (defined below) in application.rb  :</p>
<textarea name="code" class="ruby" cols="50" rows="10">
def confirm_ssl
  unless request.ssl?
    request.env["HTTPS"] = "on"
    redirect_to "/"
    return
  end
end
</textarea>
<p>By adding this method as before_filter in application.rb your application will check for https, if the request is not of type https it will redirect to an https request.
</p>
]]></content:encoded>
			<wfw:commentRss>http://webonrails.com/2007/09/13/running-rails-application-on-https-with-pound/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Deploying rails application with pound as a Balancer</title>
		<link>http://webonrails.com/2007/09/13/deploying-rails-application-with-pound-as-a-balancer/</link>
		<comments>http://webonrails.com/2007/09/13/deploying-rails-application-with-pound-as-a-balancer/#comments</comments>
		<pubDate>Thu, 13 Sep 2007 12:40:38 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
		
		<category>Rails</category>

		<category>RubyonRails</category>

		<category>Technology</category>

		<category>Web Development</category>

		<category>hosting</category>

		<category>pound</category>

		<category>mongrel_cluster</category>

		<category>deployment</category>

		<guid isPermaLink="false">http://webonrails.com/2007/09/13/deploying-rails-application-with-pound-as-a-balancer/</guid>
		<description><![CDATA[Now a days Apache + mod_proxy + mongrel_clusters, Lighttpd + Mongrel cluster and Nginx + mongrel cluster are well known for deploying rails applications. 
You can also deploy your rails application with pound(a reverse proxy, load balancer and HTTPS front-end for Web server). 
First you need to setup mongrel_clusters for your rails application by issuing [...]]]></description>
			<content:encoded><![CDATA[<p>Now a days Apache + mod_proxy + mongrel_clusters, Lighttpd + Mongrel cluster and Nginx + mongrel cluster are well known for deploying rails applications. </p>
<p>You can also deploy your rails application with <a href="http://www.apsis.ch/pound/"  target= "_blank">pound</a>(a reverse proxy, load balancer and HTTPS front-end for Web server). </p>
<p>First you need to setup mongrel_clusters for your rails application by issuing &#8221; <strong>mongrel_rails cluster::configure -e production -p 8000 -a 127.0.0.1 -N 3 -c ./</strong> &#8221; inside the rails application root directory(on client machine). This will create mongrel_cluster.yml in config directory. You can change parameters in this command, as -p 8000 specifies that mongrel instances  will start  up on port  number starting 8000, -a 127.0.0.1 specifies that mongrel instances will listen to the localhost, -N specifies the number of mongrel instances and -c specifies the rails root directory.</p>
<p>Now you need to install pound(if not installed) by issuing following commands(as root):</p>
<ul>
<li>cd /opt/src</li>
<li>wget http://www.apsis.ch/pound/Pound-2.3.2.tgz</li>
<li>tar xzpf Pound-2.1.6.tgz</li>
<li>cd Pound-2.1.6</li>
<li>./configure</li>
<li>make</li>
<li>make install</li>
</ul>
<p>This will install pound in /usr/local/sbin/pound. In order to proceed further we need to create pound.cfg(pound configuration file) in /etc/pound/pound.cfg . Below is the content of pound.cfg:</p>
<textarea name="code" class="c++" cols="50" rows="10">
                                             
User "pound"
Group "pound"

ListenHTTP
  Address 0.0.0.0
  Port 80
  Service
    BackEnd
      Address 127.0.0.1
      Port 8000
    End
    BackEnd
      Address 127.0.0.1
      Port 8001
    End
    BackEnd
      Address 127.0.0.1
      Port 8002
    End
  End
End
</textarea>
<p>Start mongrel cluster by issuing mongrel_rails cluster::start in you app root directory, start pound by /usr/local/sbin/pound -f /etc/pound/pound.cfg , now you are done. Pound is listening the port 80 and redirect all requests to mongrel instances running on 8000, 8001, 8002.</p>
<p>* Please Note that we have configured pound at port 80, if port 80 is being used by apache or any other application pound will not start. You need to stop any service using  port 80, if it is apache then stop apache, change line &#8216;Listen 80&#8242; to &#8220;Listen 8080&#8243; and start apache.</p>
<p>In a specific case, when apache is running at some port (let say 8080), you may want to use apache to serve static content of your application, in order to reduce some load from mongrels. In that case use the following:</p>
<textarea name="code" class="c++" cols="50" rows="10">
                                             
User "pound"
Group "pound"

ListenHTTP
  Address 0.0.0.0
  Port 80
  Service
      URL "/(images|stylesheets|flash|javascripts)/"
      BackEnd 
          Address 127.0.0.1
          Port    8080   
      End
      Session 
          Type    BASIC   
          TTL     300     
      End
  End
  Service
    BackEnd
      Address 127.0.0.1
      Port 8000
    End
    BackEnd
      Address 127.0.0.1
      Port 8001
    End
    BackEnd
      Address 127.0.0.1
      Port 8002
    End
  End
End
</textarea>
<p>This will redirect all requests for image, stylesheets, javascripts, flash to apache. Now we need to configure apache to serve those static content. Just add a virtualhost for that:</p>
<textarea name="code" class="c++" cols="50" rows="10">
<VirtualHost *:8080>
  ServerName example.com
  ServerAlias www.example.com
  DocumentRoot /var/www/html/example.com/public
  <Directory "/var/www/html/example.com/public" >
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>

  RewriteEngine On

  # For static files it's good to avoid hitting your mongrel process
  # so let apache knows it should serve it directly
  # for a rails application it means, files in images / stylesheets / javascripts
  RewriteRule "^/(images|stylesheets|flash|javascripts)/?(.*)" "$0" [L]

</VirtualHost>
</textarea>
<p>Its all done. All requests for dynamic content at port 80 will be redirect to mongrel running at 8000, 8001, 8001 and requests for static content will be served by apache running at port 8080.
</p>
]]></content:encoded>
			<wfw:commentRss>http://webonrails.com/2007/09/13/deploying-rails-application-with-pound-as-a-balancer/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Acts_as_solr: Starting solr server on windows</title>
		<link>http://webonrails.com/2007/09/13/acts_as_solr-starting-solr-server-on-windows/</link>
		<comments>http://webonrails.com/2007/09/13/acts_as_solr-starting-solr-server-on-windows/#comments</comments>
		<pubDate>Thu, 13 Sep 2007 08:54:40 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
		
		<category>Rails</category>

		<category>Rails Plugins</category>

		<category>Ruby</category>

		<category>RubyonRails</category>

		<category>Technology</category>

		<category>solr</category>

		<category>acts_as_solr</category>

		<guid isPermaLink="false">http://webonrails.com/2007/09/13/acts_as_solr-starting-solr-server-on-windows/</guid>
		<description><![CDATA[I was using acts_as_searchable for one of my project, which uses Hyperestraier in background. Yesterday I decided to use acts_as_solr which uses solr(based on Lucene Java search library). I did all written in its Manual/Readme, but when I issued 
 
rake solr:start

to start the solr server, it threw a heart breaking &#8220;Bad file descriptor&#8221; error, [...]]]></description>
			<content:encoded><![CDATA[<p>I was using acts_as_searchable for one of my project, which uses Hyperestraier in background. Yesterday I decided to use acts_as_solr which uses solr(based on Lucene Java search library). I did all written in its Manual/Readme, but when I issued </p>
<textarea name="code" class="ruby" cols="50" rows="10"> 
rake solr:start
</textarea>
<p>to start the solr server, it threw a heart breaking &#8220;Bad file descriptor&#8221; error, although acts_as_solr was working fine on one of my colleague&#8217;s linux machine. </p>
<p>I started digging around this and found that there is an issue in rake task that starts the solr server. Actually the problem was this rake task uses &#8216;fork&#8217; which is not available on windows, also it only handles &#8216;ECONNREFUSED&#8217; exception which is actually &#8220;Connection Refused&#8221; error raised by ruby on linux. But in windown it throws &#8216;EBADF&#8217; which is &#8220;Bad file descriptor&#8221; error raised by ruby on windows. </p>
<p>So below is the hack for that:</p>
<textarea name="code" class="ruby" cols="50" rows="10">
  desc 'Starts Solr. on windows . Options accepted: RAILS_ENV=your_env, PORT=XX. Defaults to development if none.'
  task :start_win do
    begin
      n = Net::HTTP.new('localhost', SOLR_PORT)
      n.request_head('/').value 

    rescue Net::HTTPServerException #responding
      puts "Port #{SOLR_PORT} in use" and return

    rescue Errno::EBADF #not responding
      Dir.chdir(SOLR_PATH) do
          exec "java -Dsolr.data.dir=solr/data/#{ENV['RAILS_ENV']} -Djetty.port=#{SOLR_PORT} -jar start.jar"
        sleep(5)
        puts "#{ENV['RAILS_ENV']} Solr started sucessfuly on #{SOLR_PORT}, pid: #{pid}."
      end
    end
  end
</textarea>
<p>Just add this to vendor/plugins/acts_as_solr/lib/taks/solr.rake, and start solr server on windows by issuing </p>
<textarea name="code" class="ruby" cols="50" rows="10">
rake solr:start_win
</textarea>
]]></content:encoded>
			<wfw:commentRss>http://webonrails.com/2007/09/13/acts_as_solr-starting-solr-server-on-windows/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Customizing CruiseControl build for RSpec</title>
		<link>http://webonrails.com/2007/08/30/customizing-cruisecontrol-build-for-rspec/</link>
		<comments>http://webonrails.com/2007/08/30/customizing-cruisecontrol-build-for-rspec/#comments</comments>
		<pubDate>Thu, 30 Aug 2007 09:52:35 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
		
		<category>Rails</category>

		<category>Ruby</category>

		<category>RubyonRails</category>

		<category>Technology</category>

		<category>Web Development</category>

		<category>CruiseControl</category>

		<category>Tools</category>

		<guid isPermaLink="false">http://webonrails.com/2007/08/30/customizing-cruisecontrol-build-for-rspec/</guid>
		<description><![CDATA[Yesterday I posted about CruiseControl for Rails projects. It was working fine with all my rails projects using traditional test cases, But today I faced a problem with a project using RSpec. Actually, By default CruiseControl follows the following step to build:

rake db:test:purge
rake db:migrate
rake test

This default was not working with my last project As I [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I posted about CruiseControl for Rails projects. It was working fine with all my rails projects using traditional test cases, But today I faced a problem with a project using RSpec. Actually, By default CruiseControl follows the following step to build:</p>
<ol>
<li>rake db:test:purge</li>
<li>rake db:migrate</li>
<li>rake test</li>
</ol>
<p>This default was not working with my last project As I was using RSpec for my project. I found that we can overwrite default way of building by creating a rake task named <strong>cruise</strong> in our project. Means by building CruiseControl will run your custom rake task only, so you have to take care of all other things i.e. migrate etc.</p>
<p>Hence I created following rake task in RAILS_ROOT/lib/tasks/custom_cc.rake</p>
<textarea name="code" class="ruby" cols="50" rows="10">
desc 'Custom curise task for RSpec'
task :cruise do
      ENV['RAILS_ENV'] = 'test'

      if File.exists?(Dir.pwd + "/config/database.yml")
        if Dir[Dir.pwd + "/db/migrate/*.rb"].empty?
          raise "No migration scripts found in db/migrate/ but database.yml exists, " +
                "CruiseControl won't be able to build the latest test database. Build aborted."
        end

        # perform standard Rails database cleanup/preparation tasks if they are defined in project
        # this is necessary because there is no up-to-date development database on a continuous integration box
        if Rake.application.lookup('db:test:purge')
          CruiseControl::invoke_rake_task 'db:test:purge'
        end

        if Rake.application.lookup('db:migrate')
          CruiseControl::reconnect
          CruiseControl::invoke_rake_task 'db:migrate'
        end
      end

      CruiseControl::invoke_rake_task 'spec:all'
end
</textarea>
<p>and it worked for my rails project using RSpec.
</p>
]]></content:encoded>
			<wfw:commentRss>http://webonrails.com/2007/08/30/customizing-cruisecontrol-build-for-rspec/feed/</wfw:commentRss>
		</item>
		<item>
		<title>CruiseControl.rb: A Continuous integration tool for your rails projects.</title>
		<link>http://webonrails.com/2007/08/29/cruisecontrolrb-a-continuous-integration-tool-for-your-rails-projects/</link>
		<comments>http://webonrails.com/2007/08/29/cruisecontrolrb-a-continuous-integration-tool-for-your-rails-projects/#comments</comments>
		<pubDate>Wed, 29 Aug 2007 09:38:25 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
		
		<category>Rails</category>

		<category>Ruby</category>

		<category>RubyonRails</category>

		<category>Technology</category>

		<category>CruiseControl</category>

		<category>Tools</category>

		<guid isPermaLink="false">http://webonrails.com/2007/08/29/cruisecontrolrb-a-continuous-integration-tool-for-your-rails-projects/</guid>
		<description><![CDATA[We at vinsol recently started using CruiseControl for our rails project. CruiseControl is a continuous integration tool. Which keeps an eye on you code repository and runs  all test cases (or the command you specify) whenever new version of code is found, it also sends a mail to all members specified when testcases fails [...]]]></description>
			<content:encoded><![CDATA[<p>We at <a href="http://vinsol.com" target="_blank">vinsol</a> recently started using <a href="http://cruisecontrolrb.thoughtworks.com/ "  target="_blank">CruiseControl</a> for our rails project. CruiseControl is a continuous integration tool. Which keeps an eye on you code repository and runs  all test cases (or the command you specify) whenever new version of code is found, it also sends a mail to all members specified when testcases fails with details. I found this tool very helpful and customizable. If you don&#8217;t use <a href="http://cruisecontrolrb.thoughtworks.com/"  target="_blank">CruiseControl</a> , I suggest you to give it a try.
</p>
]]></content:encoded>
			<wfw:commentRss>http://webonrails.com/2007/08/29/cruisecontrolrb-a-continuous-integration-tool-for-your-rails-projects/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
