Tooltips for Rails Validation Errors

Posted by jeff Friday, May 09, 2008 17:47:00 GMT

A while back we talked about humanizing validation error header messages in Rails. Mike Sepcot now shows you to create error-specific tooltips by using a custom FormBuilder. Very cool stuff, so check it out.

I'm on twitter, for some reason

Posted by jeff Saturday, May 03, 2008 15:49:00 GMT

There’s a scene in Jurassic Park that’s one of my favorites. The chaos theory guy – my favorite character in the movie – is explaining to everyone else in the jeep that life can be unpredictable.

While he’s explaining his theory, the other people in the jeep get so curious about the dinosaurs, that they break the Big Rule and, one by one, open their doors and get out of the jeep.

Chaos theory guy is left alone in the jeep, talking to himself, saying how he’s right because who could have predicted that everyone else would just up and get out of the jeep, leaving him all alone. Finally, he gets out of the jeep too.

Well, I feel like everyone else up and went somewhere and I’ve been missing something. Apparently there’s something big to go and see outside the jeep. So at long last, I’m going along to see what this Twitter stuff is all about.

Find me at http://twitter.com/jeffcohen.


The two best scenes in the movie, in my very humble opinion which is always right, are the shaving cream can (particularly at 1:22) and the dinner argument (particularly at 2:00). Just because you can use a particular technology, doesn’t mean that you should. I think that applies at 80% of what’s on the internet these days. I have a feeling it also applies to twitter. It’s a great shaving cream can, apparently. But since everyone else has already left my jeep, I think I will at least give it a try.

Change to comment markup

Posted by jeff Tuesday, April 29, 2008 16:03:00 GMT

I’ve switched our comment system from Markdown to Textile, so that underscores won’t cause unexpected italics anymore.

You can put inline code within @-signs (@code goes here@) or multiline code fragments can be wrapped with HTML pre tags.

Using Thin Instead Of Mongrel

Posted by jeff Sunday, April 27, 2008 17:13:00 GMT

I’m learning how to switch from mongrel to thin. If you’ve never heard about thin, you can try to read the documentation, learn about the new-cool-kid-on-the-block Rack specification, or just take my word for it: thin is better than mongrel, so just use it, ok?

It can be intimidating to try something that’s got buzz about it but you don’t really know how to get started and no one seems to really be stopping to explain it in English. So if you’re still using script/server to start mongrel or webrick, and are interested in something new, then read on.

The main reason people switch from mongrel to thin is for improved performance on their servers. But for me to learn something new, I have to first dogfood it in my development environment first. That’s what I’ll be covering in this article, and in an article coming soon to a blog near you I’ll explain how to replace your mongrel configurations with a thin configuration instead.

One note: thin is currently best suited for Mac and Linux people. I’ve used it on Windows as simple script\server replacement, but on Windows background (“daemon”) mode isn’t supported, nor is clustering, so Mongrel is still my choice on Windows boxes.

gem install thin

It won’t wreck your computer. Honest. Just do it.

Using thin to replace script/server

script/server doesn’t know to startup thin instead of mongrel (as of Rails 2.0.2). So instead, you just go to your RAILS_ROOT and do this:

myapp$ thin start

You’ll see it start up on port 3000 using the “Rails adapter.” (Turns out thin can support a variety of Ruby frameworks, not just Rails).

Need to use a different port, say, 4000?

myapp$ thin start -p 4000

On Mac/Linux, you could use script/server -d. With thin, you also use -d:

myapp$ thin start -d

To stop thin that’s been start with -d, you just, um, stop it:

myapp$ thin stop

By default, thin will create .pid files in your applications /tmp folder. If you prefer to keep your .pid files in the log directory like Mongrel did, you can specify that:

myapp$ thin start --pid log/thin.pid

Just be sure to stop it the same way:

myapp$ thin stop --pid log/thin.pid

More Options

Do a thin -h to see all the possible options. I’ll highlight just a couple more.

To specify your Rails environment, use -e just like with Mongrel:

myapp$ thin start -e production

Stopping and restarting the server is easier than it was with mongrel:

myapp$ thin restart

(Remember to also use your -e, -d,—pid, etc. options here as well if you need to.)

Next Time

Next time we’ll talk about how to setup a cluster of thin instances on your server, instead of using mongrel_cluster.

And I’d also like to be able to answer any other questions about script/server, mongrel, thin, nginx, apache, or why the Blackhawks missed the playoffs again this year. Leave a comment with your suggestions and questions if you’re so inclined.

Creating Edge Rails Projects via Git on Windows or Mac

Posted by jeff Thursday, April 24, 2008 15:19:00 GMT

Brian Hogan has a sequel to his original article for creating a local Rails project with the edge version of Rails. Now that Rails is in Git instead of Subversion, Windows users especially have to jump through a hoop or two to get the code down.

For those new to Rails, “edge Rails” referes to the latest bleeding edge of the Rails code (the “nightly builds”, if you will, though edge rails is built continuously as patches are submitted, not just nightly). Creating a new Rails project with edge rails, instead of a released version like 2.0.2, allows you to start learning about the features that will be in the next version. If you (like me) like to do that, Brian’s article is a great resource.