uninitialized constant SwitchTower (Capistrano?)

I did setup this blog (using the most excellent typo if you need to ask). The next step was to setup switchtower, and you guessed it, it almost worked. Here’s why.

Followed the directions to get it going and was ready to type my first command:

rake –trace remote_exec ACTION=setup

yeah, that would be too easy if it worked, wouldn’t it. Instead of the expected output, I get the very impolite:

** Invoke remote_exec (first_time)
** Execute remote_exec
rake aborted!
uninitialized constant SwitchTower
…/activesupport-1.2.5/lib/active_support/
dependencies.rb:200:in `const_missing’

I mean, I did not mean to be rude, so why is it doing this?

Sorry I can’t give credit to where credit is due (shame on me for not putting the info down at the time. Now that this is site is up and running, I can capture the next problem blow by blow as it happens). If you know who should get the credit, drop me a note. Anyway, here’s the solution.

in lib/taks/switchtower.rake replace


    begin
      require 'rubygems'
    rescue LoadError
      # no rubygems to load, so we fail silently
    end

    options = actions.last.is_a?(Hash) ? actions.pop : {}
to:

    begin
      require 'rubygems'
    rescue LoadError
      # no rubygems to load, so we fail silently
    end

    require 'switchtower/cli'

    options = actions.last.is_a?(Hash) ? actions.pop : {}

Incidentally, I did setup typo directly from svn to get the tagging extension builtin. And to use SwitchTower, I then commited this into my own subversion repository. This might get interesting the day I want to upgrade. We’ll keep this story for an other day.

Some non-transactional changed tables couldn’t be rolled back

Here’s an other thing that is not supposed to happen, but invariably does.

Playing aroung with Unit Testing in Rails (you are using them, right?), one test fails with:

Exception `ActiveRecord::StatementInvalid’ at
…/active_record/connection_adapters/mysql_adapter.rb:185
- Mysql::Error: Warning:  Some non-transactional changed
tables couldn’t be rolled back: ROLLBACK

Turns out that on my OS (debian), the default mysql database table type is MyISAM and it does not support ROLLBACK, try InnoDB instead.

March 12, 2006 update:

In case this is not possible, or too much problem, there is an other solution (albeit slower).

In test/test_helper.rb, change:

self.use_transactional_fixtures = true

to

self.use_transactional_fixtures = false

this way, the testing framework won’t use rollback but drop and recreate the tables each time (which explains why this is slower).

Missing default helper path

Here’s one of these things that can have you go huh?

So, here’s what happened. I created new rails app from scratch

rails ajax-test
script/generate ajax_scaffold Widget Widget
script/server

=> no page worked, only error was:

Controllers::RailsInfoController: missing default helper path
rails_info_helper when trying to access environment link

Thanks to John Martin in this post for the solution.

The solution indeed was to remove all /tmp/ruby_sess* files and restart WEBrick