Setting environment to run migrations with capistrano ext

If you’re using capistrano-ext to deploy to a different server, using a custom environment, you’ve probably noticed that it always tries to run the migrations for the production environment, like this:

cd path_to_app/deploy/releases/20100309152738; rake RAILS_ENV=production  db:migrate

Digging through capistrano’s source I found the solution is really simple, just set the rails_env variable to the environment you want, in this example staging. So inside config/deploy/staging.rb

set :rails_env, "staging"

Then when migrations get executed they’ll have RAILS_ENV=staging.

Read more →


Monthly archives for Jekyll

Recently I moved my blog to Jekyll, while being able to write stuff directly in my favorite editor EMACS, there was some functionality that I was missing from my previous custom blog engine, such as archives. Looking at how I could achieve this, I found Raoul Felix approach to the problem. Instead of patching jekyll, he wrote a small library that wraps around it, called jekyll_ext. Using it was really easy, and based on some of the extensions he created, I was able to provide this functionality in my site.

Although I had archives generated for me, I was still missing a way to display this information on my site, so I decided to create my own extension.

Read more →


View your emails with cucumber

I’ve been developing some new mailers at work, and I’ve found it really helpful to be able to view the emails as they are sent to the users. So I’ve implemented a cucumber step to help me achieve that, inspired on a similar webrat step for web pages.

Read more →


ActiveRecord migrations from the console

If you ever run into the situation where one migration doesn't complete sucessfully, and you're stuck with a column in a table or a new table, so you can't drop the migration or execute the migration again, you can always call the migration methods from the console like this:

Read more →