<?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/"
	>

<channel>
	<title>Vinsol - Leading Ruby on Rails Development and Consulting Firm in India &#187; web development</title>
	<atom:link href="http://vinsol.com/blog/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://vinsol.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 21 May 2012 13:11:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SSL checklist for Ruby on Rails Applications</title>
		<link>http://vinsol.com/blog/2010/04/01/ssl-checklist-for-rails-applications/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ssl-checklist-for-rails-applications</link>
		<comments>http://vinsol.com/blog/2010/04/01/ssl-checklist-for-rails-applications/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 08:59:02 +0000</pubDate>
		<dc:creator>sid</dc:creator>
				<category><![CDATA[RubyonRails]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://vinsol.com/blog/?p=857</guid>
		<description><![CDATA[Cross posted from darthsid The purpose of SSL is to provide a reasonable level of protection against eavesdropping and man-in-the-middle attacks. Although SSL provides a greater level of security, it introduces a lot of overheads and hence should be used sparingly. Two of the most common places to use SSL is for payment transactions and [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Cross posted from <a title="Sid's Blog" href="http://darthsid.com/blog">darthsid</a></p>
<p>The purpose of SSL is to provide a reasonable level of protection against eavesdropping and man-in-the-middle attacks. Although SSL provides a greater level of security, it introduces a lot of overheads and hence should be used sparingly.  Two of the most common places to use SSL is for payment transactions and user registration/login.<br />
This post intentionally focuses only on the Rails application as there are numerous post on the net for SSL setup on the server. Enabling SSL in a Rails application is really trivial and there are just a few points that need your attention..<br />
<span id="more-857"></span><br />
<big><big><strong>1. Enabling SSL</strong></big></big><br />
<big>a. Install the <em>ssl_requirment</em> plugin:</big></p>
<pre class="brush: bash;">
./script/plugin install git://github.com/rails/ssl_requirement.git
</pre>
<p><big>b. Include it in your <em>application_controller.rb</em>:</big></p>
<pre class="brush: ruby;">
include SslRequirement
</pre>
<p><big>c. Specify actions that require SSL in their respective controllers. For eg. my session controller has the following line:</big></p>
<pre class="brush: ruby;">
ssl_required  :new, :create if Rails.env.production?
</pre>
<p><big>d. Add the following line in <i>development.rb</i> to bypass SSL in development mode:</big></p>
<pre class="brush: ruby;">
SslRequirement.disable_ssl_check = true
</pre>
<p><big><big><strong>2. Gotcha&#8217;s</strong></big></big><br />
<big>a. Include all submit actions in requirement</big><br />
Any action that processes form data from a SSL page should also be added to the requirement. In the above example, the form on the login page(<em>new</em> action) is processed by the <em>create</em> action and hence it is also included in the requirement.<br />
<big>b. Ajax actions</big><br />
Ajax actions on a SSL page should also use SSL and must be included in the requirement. At times you do not have a body for the Ajax action and it is rendered using it&#8217;s respective RJS template. In such cases create an empty action and include it in the <em>ssl_requirement</em>.<br />
<big>c. Mixed content</big><br />
A lot of browsers show you a &#8220;Mixed Content Warning&#8221; if your SSL page references non-SSL assets. IE displays a scary looking confirmation dialog while Firefox and Chrome show a exclamation in the url bar. Any relative paths(eg. using _path helpers) on the page will automatically use the https protocol but any absolute paths(eg. using _url helper or by manually specifying as a string in link_to) will need to be changed to use https.<br />
<big>d. Asset host issue</big><br />
If you are using Rails asset hosts and do not have a SSL certificate that supports wildcard(for subdomains), then you need to disable them for the SSL pages. Just add the following code to your <em>production.rb</em>:</p>
<pre class="brush: ruby;">
ActionController::Base.asset_host = Proc.new { |source, request|
  if request.ssl?
    &amp;amp;quot;#{request.protocol}#{request.host_with_port}&amp;amp;quot;
  else
    &amp;amp;quot;#{request.protocol}assets%d.yourdomain.com&amp;amp;quot; % (source.hash % 4)
  end
}
</pre>
<p>Replace <em>&#8220;yourdomain&#8221;</em> with your apps domain and <em>&#8220;4&#8243;</em> with the number of asset hosts required.</p>
<p>The above should ensure that you have a proper SSL setup without displaying warnings to the user.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://vinsol.com/blog/2010/04/01/ssl-checklist-for-rails-applications/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Git Work Flow For Ruby on Rails Developers</title>
		<link>http://vinsol.com/blog/2009/07/24/git-work-flow-for-rails-developers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=git-work-flow-for-rails-developers</link>
		<comments>http://vinsol.com/blog/2009/07/24/git-work-flow-for-rails-developers/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 07:32:04 +0000</pubDate>
		<dc:creator>sid</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://vinsol.com/blog/?p=651</guid>
		<description><![CDATA[Cross posted from darthsid This is my very first blog post and so I though it should be about a tool that is indispensable for me &#8211; Git. I started using git about 10 months ago and looking back I can&#8217;t imagine how I managed to get work done without it. The purpose of this [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Cross posted from <a title="Sid's Blog" href="http://darthsid.com/blog">darthsid</a></p>
<p>This is my very first blog post and so I though it should be about a tool that is indispensable for me &#8211; Git. I started using git about 10 months ago and looking back I can&#8217;t imagine how I managed to get work done without it. The purpose of this post however is not to sing git&#8217;s praises, there are lots of good articles on the web that do so much better than I ever could. Instead, I wish to share the work-flow I use on my projects. I developed this work-flow by trial and error over the months and is currently the most efficient and productive approach I can think of. If any experienced git users happen to stumble upon this post, please do provide suggestions/alternatives to help me improve my process.</p>
<p>The project I am currently working on requires me to maintain two parallel deployment branches. One is a &#8220;production branch&#8221; which is deployed on the live server and the other is a &#8220;development branch&#8221; which is deployed on a staging server. All enhancements and feature additions are done in the &#8220;development branch&#8221; and the only changes made in the &#8220;production branch&#8221; are production bug fixes that need urgent attention. Once the &#8220;development branch&#8221; is deemed stable it is merged into &#8220;production branch&#8221; and deployed.<br />
<span id="more-651"></span><br />
I&#8217;ve divided my work-flow into two parts. The first part is a generic approach which I follow in all projects, the second part is specific to the case mentioned above and discusses how I manage the two branches using git. Although I mention &#8220;Rails&#8221; in the title of this post, the work-flow I define below is not &#8220;Rails&#8221; specific and can be applied to any project where multiple deployment branches need to be maintained. I assume the reader has a basic understanding of git and is comfortable with git branches. There are lots of configuration settings in git which help you setup things like you git author name, email and colors for git commands etc. There are two I would like to mention here though:</p>
<pre class="brush: bash;">git config --global push.default &amp;quot;tracking&amp;quot;</pre>
<p>This command tells git to perform a push only to the tracked remote branch in which you are currently working.</p>
<pre class="brush: bash;">git config --global pack.threads &amp;quot;0&amp;quot;</pre>
<p>This command tells git to auto-detect the number of threads to use for packing repositories and is useful when working on a machine with more than one core.</p>
<p><big><big><strong>1. Generic Workflow</strong></big></big></p>
<p><strong>a. Start with a clean master branch.</strong></p>
<pre class="brush: bash;">
git checkout master
git pull
</pre>
<p>You now have a clean master branch. Never work directly in the master branch, instead make all changes to a local branch.</p>
<p><strong>b. Create a local branch.</strong></p>
<pre class="brush: bash;">
git branch my_local_branch
git checkout my_local_branch
</pre>
<p>or do both in one command:</p>
<pre class="brush: bash;">git checkout -b my_local_branch</pre>
<p>This creates a new local branch named &#8220;my_local_branch&#8221; and switches to it. You can now perform all changes in this branch. One good practice to follow when using git is to commit often and in small chunks. This gives you finer control on the work done and allows you to fix mistakes without losing other work. Once you are satisfied, all those smaller commits can be consolidated in a single meaningful commit.</p>
<p><strong>c. Merge with master branch.</strong></p>
<pre class="brush: bash;">
git checkout master
git pull
</pre>
<p>if new changes were pulled do the following:</p>
<pre class="brush: bash;">
git checkout my_local_branch
git rebase master
</pre>
<p>A rebase will apply the newly pulled changes in the master branch to your local branch and then apply local branch changes on top of that. This will ensure a clean merge with master. Conflicts are very common during a rebase and will need to be resolved before you can have a successful rebase. You can also pass the &#8220;-i&#8221; option to rebase to perform an interactive rebase which will alllow you to squash multiple commits into one if you so require. Once you are finished with the rebase do the following:</p>
<pre class="brush: bash;">
git checkout master
git merge my_local_branch
git push
</pre>
<p>Once you are satisfied with the push you can delete the local branch:</p>
<pre class="brush: bash;">git branch -d my_local_branch</pre>
<p><big><big><strong><br />
2. Managing Multiple Deployment Branches</strong></big></big></p>
<p>The master branch is set as the branch for production deployment and a new remote branch is created for development phase. Since I use capistrano for project deployment I set it up to have three separate tasks: &#8220;production&#8221;, &#8220;production_staging&#8221; and &#8220;development_staging&#8221;. The &#8220;production&#8221; and &#8220;production_staging&#8221; tasks use the master branch and the &#8220;development_staging&#8221; task uses the newly created remote branch. For both the remote branches you must follow the above work-flow i.e: never work directly in the branches themselves, instead create local branches to work in.</p>
<p><strong>a. Create a new remote branch.</strong></p>
<p>First create a new remote branch from our master branch:</p>
<pre class="brush: bash;">git push origin master:refs/heads/development_phase_1</pre>
<p><strong>b. Track the remote branch.</strong></p>
<p>Track the newly created remote branch:</p>
<pre class="brush: bash;">git checkout --track -b development_phase_1 origin/development_phase_1</pre>
<p>This will create a new local branch named &#8220;development_phase_1&#8243; that is tracking the remote &#8220;development_phase_1&#8243; branch. Everyone who needs to work on development branch tracks this remote &#8220;development_phase_1&#8243; branch and pushes to it. The only pushes to master branch are production fixes.</p>
<p><strong>c. Merge the development branch with the master branch.</strong></p>
<p>Once work on development branch is finished we are ready to merge the two branches:</p>
<pre class="brush: bash;">
git checkout development_phase_1
git rebase master
git checkout master
git merge development_phase_1
git push
git branch -d development_phase_1
git push origin :heads/development_phase_1
</pre>
<p>Normally a rebase is not a good idea in a remotely tracked branch but since our phase is finished and we will create a new remote branch for the next phase, I do so here. Alternatively, I could do a force push for the remote development branch and everyone working on it would need to remove and retrack it again. The second last line removes our locally tracked development branch and the last one removes it from the remote repository.</p>
<p><big><big><strong>Final Thoughts</strong></big></big></p>
<p>As I mentioned before, the above presented work-flow is not perfect by any means but it works for me. I would appreciate feedback from anyone who reads this and has some  suggestions/recommendations to help me manage my projects better.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://vinsol.com/blog/2009/07/24/git-work-flow-for-rails-developers/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Funding Driven Development (FUDD)</title>
		<link>http://vinsol.com/blog/2009/04/17/funding-driven-development-fudd/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=funding-driven-development-fudd</link>
		<comments>http://vinsol.com/blog/2009/04/17/funding-driven-development-fudd/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 00:28:16 +0000</pubDate>
		<dc:creator>kapil</dc:creator>
				<category><![CDATA[announcements]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://vinsol.com/blog/?p=592</guid>
		<description><![CDATA[We live in a quick-fix society so it&#8217;s no wonder that many startups especially in technology look for the magic cure to increase their sales or get funding for their projects.  These projects follow funding driven development methodology. And here are few symptoms of  FDD : Most of these products start looking for investors  even [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" style="display: inline" title="elmer fudd" src="http://rightwingnuthouse.com/images/ElmerFudd.jpg" alt="" width="102" height="200" /></p>
<p>We live in a quick-fix society so it&#8217;s no wonder that many startups especially in technology look for the magic cure to increase their sales or get funding for their projects.  These projects follow funding driven development methodology. And here are few symptoms of  FDD :</p>
<ul>
<li>Most of these products start looking for investors  even when the core benefit web app is not properly conceptualized.</li>
<li>The product manager spends more time with PR,investors and newspapers than with developers.</li>
<li>The milestones for the project are strictly based on the next press release, media  interview or conference.</li>
<li>Instead of driving real people and customers to sales pipeline, you meet people who are not your target audience.</li>
<li>They always think of  raising capital and use major part of that in increasing/improving your sales force.</li>
<li>They lack patience and you dont want to wait for few quarters to reach the right feature set after product launch based on feedback.</li>
<li>They are least bothered about the backend and focus on UI. As long as the site looks cool , you are okay with that irrespective of the quality of  code running in the backend.</li>
<li>Instead of a single marketing launch, They have a series of launch with some new stupid feature everytime which nobody needs in every launch.</li>
<li>When investors see PR stuff of your project, they expect  significant momentum which usually is not there.PR is not writing code. You can not try it, iterate, learn, and try again.</li>
<li>The founders feel great when they are covered by leading media instead of significant release that improves their product.</li>
<li> They don&#8217;t understand the value of an early release, release often.</li>
</ul>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://vinsol.com/blog/2009/04/17/funding-driven-development-fudd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Migration: Adding/Removing columns are now much easier</title>
		<link>http://vinsol.com/blog/2008/01/23/migration-addingremoving-columns-are-now-much-easier/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=migration-addingremoving-columns-are-now-much-easier</link>
		<comments>http://vinsol.com/blog/2008/01/23/migration-addingremoving-columns-are-now-much-easier/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 17:24:54 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
				<category><![CDATA[migration]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[RubyonRails]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[web development]]></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 [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></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://vinsol.com/blog/2008/01/23/migration-addingremoving-columns-are-now-much-easier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby Script for SVN commit notification with log message, list of updated files and readable colored SVN Diff</title>
		<link>http://vinsol.com/blog/2008/01/14/ruby-script-for-svn-commit-notification-with-log-message-list-of-updated-files-and-readable-colored-svn-diff/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ruby-script-for-svn-commit-notification-with-log-message-list-of-updated-files-and-readable-colored-svn-diff</link>
		<comments>http://vinsol.com/blog/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><![CDATA[notification]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[RubyonRails]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[web development]]></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 [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></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=7" title="Version 0.1 downloaded 17 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://vinsol.com/blog/2008/01/14/ruby-script-for-svn-commit-notification-with-log-message-list-of-updated-files-and-readable-colored-svn-diff/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Single Table Inheritance validates_uniqueness_of Problem</title>
		<link>http://vinsol.com/blog/2007/10/26/single-table-inheritance-validates_uniqueness_of-problem/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=single-table-inheritance-validates_uniqueness_of-problem</link>
		<comments>http://vinsol.com/blog/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><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[RubyonRails]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[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 [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></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://vinsol.com/blog/2007/10/26/single-table-inheritance-validates_uniqueness_of-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deploying rails application with pound as a Balancer</title>
		<link>http://vinsol.com/blog/2007/09/13/deploying-rails-application-with-pound-as-a-balancer/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=deploying-rails-application-with-pound-as-a-balancer</link>
		<comments>http://vinsol.com/blog/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><![CDATA[deployment]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[mongrel_cluster]]></category>
		<category><![CDATA[pound]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[RubyonRails]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[web development]]></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 [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></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://vinsol.com/blog/2007/09/13/deploying-rails-application-with-pound-as-a-balancer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Customizing CruiseControl build for RSpec</title>
		<link>http://vinsol.com/blog/2007/08/30/customizing-cruisecontrol-build-for-rspec/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=customizing-cruisecontrol-build-for-rspec</link>
		<comments>http://vinsol.com/blog/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><![CDATA[CruiseControl]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[RubyonRails]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[web development]]></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 [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></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://vinsol.com/blog/2007/08/30/customizing-cruisecontrol-build-for-rspec/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>wanna add keyboard shortcuts to your web application?</title>
		<link>http://vinsol.com/blog/2007/04/24/wanna-add-keyboard-shortcuts-to-your-web-application/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wanna-add-keyboard-shortcuts-to-your-web-application</link>
		<comments>http://vinsol.com/blog/2007/04/24/wanna-add-keyboard-shortcuts-to-your-web-application/#comments</comments>
		<pubDate>Tue, 24 Apr 2007 17:09:42 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://webonrails.com/2007/04/24/wanna-add-keyboard-shortcuts-to-your-web-application/</guid>
		<description><![CDATA[Today I was looking for some javascript to add keyboard shortcuts to my project. And after little search on google I came across a very cool and lightweight javascript library shortcuts.js .
This library allows you to make keyboard shortcuts on a fly.
Example:

shortcut("Ctrl",function() {
	alert("Hi there!");
});

Please visit this site to know more about this javascript library. 



No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Today I was looking for some javascript to add keyboard shortcuts to my project. And after little search on google I came across a very cool and lightweight javascript library <a href="http://www.openjs.com/scripts/events/keyboard_shortcuts/shortcuts.js"  >shortcuts.js</a> .<br />
This library allows you to make keyboard shortcuts on a fly.<br />
<strong>Example:</strong></p>
<textarea name="code" class="JavaScript" cols="50" rows="10">
shortcut("Ctrl",function() {
	alert("Hi there!");
});
</textarea>
<p>Please visit <a href="http://www.openjs.com/scripts/events/keyboard_shortcuts/" >this site</a> to know more about this javascript library. </p>
]]></content:encoded>
			<wfw:commentRss>http://vinsol.com/blog/2007/04/24/wanna-add-keyboard-shortcuts-to-your-web-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>apache proxy balancer + mongrel clusters and deploying application with capistrano</title>
		<link>http://vinsol.com/blog/2007/02/04/apache-proxy-balancer-mongrel-clusters-and-deploying-application-with-capistrano/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=apache-proxy-balancer-mongrel-clusters-and-deploying-application-with-capistrano</link>
		<comments>http://vinsol.com/blog/2007/02/04/apache-proxy-balancer-mongrel-clusters-and-deploying-application-with-capistrano/#comments</comments>
		<pubDate>Sun, 04 Feb 2007 14:20:25 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://webonrails.com/2007/02/04/apache-proxy-balancer-mongrel-clusters-and-deploying-application-with-capistrano/</guid>
		<description><![CDATA[So you want to setup production server with mongrel clusters and apache proxy balancer, also wants to use capistrano for deployment, huh. Take it easy, its very simple.
You need Apache 2.2 or later on your production server, and the following ruby gems on your both machine(server and local):

capistrano
mongrel
mongrel_cluster

I haven&#8217;t mentioned rails and rake gem as [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>So you want to setup production server with mongrel clusters and apache proxy balancer, also wants to use capistrano for deployment, huh. Take it easy, its very simple.</p>
<p>You need Apache 2.2 or later on your production server, and the following ruby gems on your both machine(server and local):</p>
<ul>
<li>capistrano</li>
<li>mongrel</li>
<li>mongrel_cluster</li>
</ul>
<p>I haven&#8217;t mentioned rails and rake gem as we are deploying a rails application so these gems are obvious.</p>
<p>Lets install above gems (if not installed)  by issuing:</p>
<textarea name="code" class="ruby" cols="50" rows="10">

gem install --include-dependencies capistrano
gem install --include-dependencies mongrel
gem install --include-dependencies mongrel_cluster

</textarea>
<p>Now make sure that the following modules are enabled (they are disabled by default) :</p>
<ul>
<li>mod-rewrite</li>
<li>mod-proxy</li>
<li>mod-proxy-http</li>
<li>mod-proxy-balancer</li>
</ul>
<p>to check if they are enabled issue &#8221; <strong>/etc/init.d/apachectl -M</strong> &#8221; on server, it will list all the enabled modules. For Debian systems all enabled modules are in /etc/apache2/mods-enabled directory and all available modules are in  /etc/apache2/mods-available directory, to enable them issue &#8221; <strong>a2enmod MOD_NAME</strong> &#8220;.</p>
<p>Now create the production database(on server) and update database.yml for production database settings.</p>
<p>After this configure mongrel by issuing &#8221; <strong>mongrel_rails cluster::configure -e production -p 8000 -a 127.0.0.1 -N 2 -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 its time to capistranize rails application, issue &#8221; <strong>cap &#8211;apply-to ./ APP_NAME</strong> &#8221; inside rails application root directory(on client machine), this will add two files(config/deploy.rb and lib/tasks/capistrano.rake) to the rails application. Edit deploy.rb according to your requirements. Also add the following code to deploy.rb :</p>
<textarea name="code" class="ruby" cols="50" rows="10">
task :restart, :roles => :app do
# stop mongrel clusters for previous release and start for current
run "cd #{previous_release} &#038;& mongrel_rails cluster::stop"
run "sleep 5"
run "cd #{current_release} &#038;& mongrel_rails cluster::start"
end
</textarea>
<p>Now on your local machine issue these two commands in only once &#8221; <strong>rake remote:setup</strong> &#8221; and &#8221; <strong>rake remote:cold_deploy</strong> &#8220;, when you issue &#8221; <strong>rake remote:setup</strong> &#8221; it will prompt for the server password and create necessary directories on the server and &#8221; <strong>rake remote:cold_deploy</strong> &#8221; will deploy your code to the server. Next time whenever you want to deploy to the server you just need to issue &#8221; <strong>rake remote:deploy</strong> &#8221; not &#8221; <strong>rake remote:cold_deploy</strong> &#8220;.</p>
<p>Now we are just one step back, we need to configure apache proxy balancer for mongrel instances. Add the following code to the httpd.conf file:</p>
<textarea name="code" class="c++" cols="50" rows="10">

<Proxy balancer://mongrel_cluster>
BalancerMember http://127.0.0.1:8000
BalancerMember http://127.0.0.1:8001
</Proxy>

<VirtualHost *:80>
ServerName myapp.com
DocumentRoot /rails_apps/app/public

<Directory "/rails_apps/app/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

RewriteEngine On


RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]


RewriteRule ^/$ /index.html [QSA]
# Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ $1.html [QSA]


RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]
</virtualHost>
</textarea>
<p>you need to change the above code according to you requirement. Also you need to restart apache server by issuing &#8221; <strong>/etc/init.d/apachectl restart</strong> &#8220;. Now you are done.</p>
<p>But we also need to add a script to start mongrel instances when the server restarts, otherwise whenever the server restart there will no mongrel instance running.</p>
<p>Just create a file named mongrel_clusters (you can choose any name) in /etc/init.d directory with the following code:</p>
<textarea name="code" class="c++" cols="50" rows="10">

#!/bin/bash
#
# chkconfig: 345 94 16
# description: Startup script for mongrel
BASEDIR=/var/www/your_app
export HZ=100
export TERM=linux
export SHELL=/bin/bash
export HUSHLOGIN=FALSE
export USER=root
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
export MAIL=/var/mail/root
export _=/usr/bin/env
export PWD=/etc/init.d
export HOME=/root
export SHLVL=2
export LOGNAME=root

cd $BASEDIR
case "$1" in
start)
echo "starting up mongrel in $BASEDIR"
mongrel_rails cluster::start
;;
stop)
echo "stopping mongrel"
mongrel_rails cluster::stop
;;
restart)
mongrel_rails cluser::stop
sleep 3
mongrel_rails cluster::start
;;
esac
</textarea>
<p>You need to change the BASEDIR in the above code. Make this file executable by &#8221; <strong>chmod +x /etc/init.d/mongrel_clusters</strong> &#8221;<br />
Issue these commands to add this script at system startup:</p>
<p><strong>Debian:</strong><strong> /usr/sbin/update-rc.d /etc/init.d/mongrel_clusters defaults</strong><br />
<strong>RedHat:</strong>  <strong>/usr/sbin/chkconfig &#8211;add /etc/init.d/mongrel_clusters</strong> and <strong>/usr/sbin/chkconfig &#8211;level 2 /etc/init.d/mongrel_clusters on</strong></p>
<p>Note: Use above instructions at your own risk, if your computer explodes its not my fault :-)
</p>
]]></content:encoded>
			<wfw:commentRss>http://vinsol.com/blog/2007/02/04/apache-proxy-balancer-mongrel-clusters-and-deploying-application-with-capistrano/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

