Archive for the 'Rails' Category

Capistrano via Cron or FreeBSD Periodic

Tuesday, May 5th, 2009

Running Capistrano from cron or FreeBSD’s periodic can be tricky—both (wisely) limit your environment. Scripts may run just fine in a SSH session, but fail when run by cron.A couple of standard gotchas:

  • Command not found: your PATH is usually chopped down. Either explicitly set PATH to include you commands, or execute commands with their full paths.
  • No terminal. On Linux, try sudo’s -i option.

More puzzling:connection failed for: (RuntimeError: can’t get terminal parameters (Inappropriate ioctl for device))I assumed this was a tty/SSH/login session problem. Turns out it was a permissions problem. The current user couldn’t login to the remote server via SSH, and the remote server was prompting for a password. Of course, it worked when running this script by hand.

Rails 2.3 Plugin Routes

Thursday, March 19th, 2009

As noted here and here, Rails 2.3 will load routes from a plugin. If the plugin is considered an engine. A blank “app” directory in your plugin’s root is enough for the plugin loader.

Google Group for Racing on Rails

Tuesday, July 29th, 2008

There was a burst of interest in WSBA website development on their mailing list—enough to annoy a few non-coders at any rate. So Racing on Rails has its own Google Group for development. Here’s hoping it’s the tip of the volunteer Rails coder cyclist iceberg.

For those late to the party or too lazy to click the link above, Racing on Rails is the Ruby on Rails application behind several bike racing association websites like the WSBA and OBRA. It’s all open source (except for the association-specific parts), and it pretty much works OK at this point.

I’ve put a lot of time into this code in the last few years. Plenty of cool ideas abound for these sites—it would be great to have more developers to make those ideas happen.

We’re Hiring Another Rails Developer

Wednesday, February 6th, 2008

“We” means Analog Analytics. It’s fun, personally, to be hiring now instead of trying to be hired. Here’s the job description:

“Terrific opportunity for talented developer to join an exciting team helping to change the advertising industry.”

It’s a remote position — Pacific time zone strongly preferred — I’m in Portland, the CTO is in Los Angeles, and the CEO is in San Diego. There’s no home office. We deploy and develop Rails (and a little C) on OS X, Linux, and Solaris.

Light on the details? Sure. We’re not hung up on any many specific qualifications. Want to earn your salary coding in Rails? Email me at

Rails 2 upgrade: .rhtml to .html.erb Script

Wednesday, January 16th, 2008

This is less a post, than a note to myself, but anyway, here’s a handy script to change your view extensions while preserving Subversion history.

#! /usr/bin/env ruby
require 'pathname'
for path in Dir['app/views/**/*.rhtml']
pathname =
p `svn mv #{path}#{pathname.dirname}/#{pathname.basename.to_s.split('.').first}.html.erb`

undefined method `dbman’

Sunday, November 18th, 2007

Upgrading to a Rails app to 2.0 and seeing this error?

undefined method `dbman' for #<ActionController::TestSession

You need to add this line to config/environments/test.rb:
config.action_controller.allow_forgery_protection = false

Obvious to you, maybe, but not to me.

Dumb Thing I Did Recently With Rails

Tuesday, October 30th, 2007

Turns out that dashes are not really valid hostnames in URLs. So, ‘’ is valid, but ‘’ is not.

Now, Apache virtual hosting will work with underscores just fine, as did 1.1 versions of Rails and Safari 2.0. I think IE never liked it. By “worked” and “liked,” I mean that the browser accepted cookies from the host. If the browser doesn’t accept the cookies, then Rails creates a new session for each request, and that prevents you from logging in to sites like

Safari 3 show the same behavior. In fact, with Rails 1.2, the only browser that “works” is Firefox.

Anyway, long story short: don’t use underscores in hostnames.

Final Keynote by Dave Thomas

Wednesday, May 30th, 2007

I have to say that all the RailsConf keynotes I went to were good, and I heard that the others were good, too. Is that level of quality sustainable? I hope so.

Dave noted that EuroRailsConf was the most profane conference ever. He thought this was a bad thing.

We all were getting a bit loopy at this point, so my notes are short and fragmented. Here’s what I can piece back together.

Ze Frank talked about what to do when you have many amateur authors. This was an interesting problem that we wrestled with back in the day at Gap Inc.’s intranet. You can ignore them (obvious bad consequences). You can try and control them, but this doesn’t scale. You can shut them down (draconian). He suggests that you instead facilitate conversation. Which sounds fine, but fuzzy now that I write it down here. Should have gone to his talk, I guess.

Dave warned about Cargo Cult programming — definitely a danger in the Rails community. He then listed some assumptions we should question:
– The web browser: it’s a freakin’ full-duplex mainframe terminal!
– Object-oriented programming. The world is not hierarchial, it’s chaotic. Why are we so class-centric? Try to write a program without classes and you might be surprised by how it works.
– Relational databases

Laying Tracks: How to Contribute to the Ruby on Rails Open Source by Josh Susser

Wednesday, May 30th, 2007

This talk was practical advice on how to do just what the title says: contribute to Rails.

Josh comes from a Smalltalk background. He also worked on OpenDoc, “A technology that no one has heard of it.” You are wrong, my friend — I remember when it was all the buzz at MacWorld Boston ‘96, and my boss was wondering if we should become OpenDoc developers. Ah, CyberDog, we shed a tear for you.

Anyway, Josh now works at Java Card.

The session’s audience:
15% use the Rails Trac
10-15% opened a ticket
10% contributed a patch
5% had patch accepted

Prerequisites for contributing: Rails Trac account, Subversion, subscribe to the Rails Core discussion list.

First steps:
1. Create a local, vanilla Rails projects for this work
2. svn co to vendor
3. Set up tests
4. Ensure tests run

You need to use TDD, follow code style, write docs, write tests, and ensue that the rdoc builds. Use SVN diff to generate patch. Create a Trac ticket with [PATCH] in the subject.

How to get some patch accepted
– Make tiny changes
– Discuss big patches first on Rails Core
– Need good code
– Need tests
– Get buy in for Rails developers

“Get used to disappointment. “There’s a backlog.

JRuby on Rails: A Taste of Honey (for the Enterprise) by Charles Nutter, Thomas Enebo

Wednesday, May 30th, 2007

Here’s a real advantage of a conference over email: I learned that Charles Nutter has an awesome Midwestern accent! I’ve got a whole new voice in my head while I read his posts, and there are a lot of them. Does Charles Nutter sleep? He seems to churn out emails and blog comments about JRuby 24/7.

On to the talk. For the record, I am not sure how I feel about the whole Rails running on JRuby inside a WAR on Glassfish stack at the enterprise data center. Sounds like a tall, tipsy stack of dinnerware to me. But I do like JRuby. It’s been really handy at C o n – w a y for calling EJBs, using mainframe proxies, and running JUnit test suites. And there’s a real possibility that the Java VM could become a great VM for Ruby.

This session’s poll:
25% of the audience are Java developers
25% ex-Java developers
15% ex-Perl users

Who uses which database?
40% MySQL
5% SQLite
10% MS SQL Server
20% Oracle
1% DB2

Why use JRuby instead of C Ruby?
– Unicode support
– Native JVM threads
– The big pain point …

What are the biggest differences?

1) Database support. Ruby MySQL works about the same. JRuby can use JDBC, of course, and JNDI to look up connection pools. DB2 support is not 100%? (Works pretty good for me.) Oracle ActiveRecord tests are not 100%

2) Native Ruby extensions don’t work out of the box. Need porters.

3) Command-line performance because Java start-up time is slow.

Charles and Thomas demoed Goldspike, a way to package a Rails app into a J2EE WAR:
rake war:standalone:create

And they demoed a Glassfish gem! Hm, well, theoretically, if all this just works, it could be pretty cool. Though I dread digging through the stack trace.