cap deploy_with_migrations default behaviour

When using cap deploy_with_migrations, the default behaviour is to deploy with the migrations in the production environment.

To change this behavior add:

in your config/deploy.rb

Keeping uploaded files between deployments

You are using file_column plugin (or maybe another plugin?), to upload files in your ruby on rails application. Because the files are big you don’t want to have a different copy stored in your subversion repository for each different deployment version. You want to keep a common folder with all your uploaded files, and use it with every different deployment version.

For the example, we will have a numbers table that has two file_column uploadable columns (intro,voice_mail), with the following migration:

  1. If you already have used cap deploy or cap setup you should have a shared folder in your deployment server.
    You should copy the intro and vmail folders that should be located on your public/number folder on your local development client, on a folder called number in your development server in your shared folder.
  2. Create a file in your local pc in lib/cap_recipes.rb:

    Be careful with the naming of the task as (at least for capistrano 1.4 that I’m using), it must have a special name as after_symlink.
    Also be careful that if you try to use before_symlink, it won’t work as the current symlink won’t be setup.
  3. In your config/deploy.rb file add at the top the following:
  4. Now you should be ready to deploy your new version so:

    make sure that you check in your version in subversion, and then:

    you should be able to see a link in your current/public folder called number that points to the shared/number folder that hold all the uploaded files.

Adding icons to ActiveScaffold’s actions

You want to replace the standard text descriptions in ActiveScaffold’s actions with your icons.


  1. Create a file called active_scaffold_overrides.css in ror_project/public/stylesheets
  2. Copy the css code from ror_project/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet.css and paste it in to the file created in the previous step.
  3. Create a directory my_images in ror_project/public/images/activescaffold to hold your images.
  4. Copy to the new directory the images you want to use in the application.
  5. In the active_scaffold_overrides.css file find the section named:

    and for each action that you want to use an icon add (ie edit)
  6. In the application.rb, if you want the links to be the same for the whole application add:
  7. in your layout/application.rhtml (create one if you don’t already have one), include
  8. Restart webrick/mongrel

Controller testing in Active Scaffold


You need to have to functionally test your controller when you are using ActiveScaffold. There are pieces of code that tell you how to do that on a normal ror application (ie without ActiveScaffold), like recipe 7.17 on the Rails Cookbook, or a fragment of code in an Active Scaffold application, but they don’t have the full details.


Here is an attempt to give some more detailed step by step instructions on how to do it.

  1. The migration for the example customer model.
  2. The customer model, with the extra function to display the customer code
  3. The customer controller app/controllers/customers_controller.rb, using the Active Scaffold
  4. The fixtures YML file test/fixtures/customers.yml
  5. And here are some functions to test some pages and a full CRUD test

:int and :integer problem in Ruby on Rails migration

After spending some time trying to make a migration work, and having the error message coming back:

I’ve decided to do a google search for the specific problem, as it was working fine with other test migrations.

It turns out that if the migration is not model specific, but a different one (ie trying to add a new column to an existing table), the :int for the column doesn’t work!
It has to be :integer.
Full bug report and the article are here:
Migrations: :integer works, :int doesn’t – datatype discrepancy

dhtmlcalendar in ActiveScaffold

To control the date format in dhtmlcalendar within ActiveScaffold in Ruby on Rails, to make the date of 2 November 2007 appear like 02-11-2007, use:

i) if you want to affect the settings in all the application add the following to the top of your controllers/application.rb

ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMAT[:default] = ‘%d-%m-%Y’

ii) If you only want to affect the settings of the calendar in one specific controller, then add the same line only to the controller that you want: