December 2011
1 post
Storing IP addresses the smarter way
If you need to store an IP address in a database, it’s possibly because you’re logging web requests or similar. This means the table can get very large, very quickly. If you’re storing the addresses in a VARCHAR, you will use up a lot of space in your table and make indexing a nightmare. A lot of people don’t know that you can represent these as an INT which is much more...
June 2011
1 post
Running Goliath on a UNIX domain socket
EventMachine supports listening on UNIX domain sockets, therefore Goliath does too.
Simply create a config file as per the instructions on the wiki with the following:
@port = nil
This makes EventMachine take the address parameter as a unix socket, so simply run your server in the following way:
ruby hello_world.rb -sva hello_world.sock
You can then serve it up using nginx:
http {
server {
...
March 2010
1 post
3 tags
Rails 3: Shoulda failing to load
If you’re trying to test a Rails 3 gem/plugin/engine and you’re using Bundler, you’re likely to run into an error like the following:
DEPRECATION WARNING: RAILS_ROOT is deprecated! Use Rails.root instead.
/Library/Ruby/Gems/1.8/gems/shoulda-2.10.3/lib/shoulda/autoload_macros.rb:40:in `join': can't convert # into String (TypeError)
from...
February 2010
2 posts
Rails 3: no such file to load -- thor/group
If you’re getting errors about loading thor when trying to run the Rails 3 binary, try the following:
ruby -r'rubygems' railties/bin/rails
You can also alias this in your .profile or .bashrc for fun and profit:
alias rails3="ruby -r'rubygems' ~/gems/rails/railties/bin/rails"
Routing in Rails 3 Engines
If you’re creating a new Engine in Rails 3 (or upgrading one from Rails 2), you’re probably wondering how to do the routing. This is how:
Rails.application.routes.draw do
namespace :admin do
resources :users
resource :session
match 'login' => 'admin/sessions#new', :as => 'login'
match 'logout' => 'admin/sessions#destroy', :as =>...
November 2009
1 post
Rubinius dependencies on Ubuntu
If you’re trying to build Rubinius on a blank Ubuntu install, you’ll likely hit missing dependancies such as readline, ossl_typ.h and readline. When you run ./configure, it’ll also says that backtrace isn’t found.
Make sure you’ve got the following packages installed, and all will be well:
ruby-dev
zlib1g-dev
libssl-dev
libreadline-dev