February 18, 2006

switchtower and lighttpd

I’ve been fighting with LightTPD 1.4.10 and Switchtower. This is on a Debian 3.1 (Sarge) box.

Lighty needed PCRE (Perl Compatible Regular Expression Library) to be useful.

sudo aptitude install libpcre3-dev

After that it kept crashing without any log messages. Eventually I found a patch that fixes the problem.

Switchtower was easy enough to install:

gem install switchtower

But it complained about openssl, so:

sudo aptitude install libopenssl-ruby

Then it freaked me out by echoing passwords. The solution is another Gem:

gem install termios

I have everything on the same machine, so I can use a file:// URI for my Subversion repository. Switchtower, however, defaults to using ssh for running commands on the production server. It can ssh to localhost, but the restricted ssh environment doesn’t include $GEM_HOME, which I need because I installed RubyGems in /usr/local.

Now I need to either change the Switchtower recipes or patch RubyGems. Yay.

posted at 19:32 -07:00 | rails | no comments

February 02, 2006

strip whitespace

Remove leading and trailing whitespace from a model’s fields:

def before_validation
  attributes.each_key {|a| self[a].strip! if self[a].respond_to? :strip! }
end

I also found a more complicated version, implemented as an Observer, on the Rails wiki.

posted at 17:31 -07:00 | rails | no comments