I extracted a few pieces of code into Rails Plugins.

  • Cars: Helpers for populating dropdowns with automobile makes and models
  • Host Router: Allows creation of routes based on hostname or port
  • Multisite: Provides site-specific view paths
  • Remote Database: Helpers for working with databases on multiple hosts
  • Fraud Guardian: Helpers for generating fraud reports via FraudGuardian

Nothing spectacular, but maybe they’ll help someone else.

I needed HTTP basic authentication for a Sinatra app running as a Rails Metal. I have two apps, one running Clearance and another running Authlogic.

Using the info from my previous post, I wrote a small Sinatra plugin that works with both Clearance and Authlogic.

Throw the file above in lib/sinatra_authentication.rb. Then, your metal, app/metals/api.rb would look something like this:

Authlogic doesn’t have an authenticate method, so I added this to app/models/user.rb:

Hope it helps someone else.

It took me a while to find a clearly documented way to manage gems without having to use sudo. Just drop these lines into your ~/.zshrc or ~/.bashrc file.

Easy.