Site Archives Web Development

Migration: Adding/Removing columns are now much easier


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 ‘role’ in users table(User model). In this case generate a migration like:

script/generate migration […]

Ruby Script for SVN commit notification with log message, list of updated files and readable colored SVN Diff


Some days ago I wrote a post about “SVN commit notification” 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 […]

Single Table Inheritance validates_uniqueness_of Problem


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 […]

Deploying rails application with pound as a Balancer


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 […]

Customizing CruiseControl build for RSpec


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 […]