Nested forms, hashes, checkboxes and MongoMapper

While working on my upcoming BigAuthor project, I came upon an interesting challenge that turned out to be so simple with MongoMapper that I just have to share it here. Need to create a hash of multiple filter parameters on a MongoMapper document using a form that is cleanly resource-based, using InheritedResources? It’s [...]

Starting a new Rails app? Here's my skeleton...

Not meant to be a “this is what should be done” as much as a “this is what Matt uses, based largely on community popularity, best practice, and Matt’s personal tastes.”

Take it for what it is: a point of discussion.

Of course, the skeleton of any Rails app will vary from project to project, depending on [...]

Why use HAML (and SASS)? I already know HTML.

The title of the post is more-or-less a verbatim quote from a coworker, as well as from an unrelated colleague of mine from a previous job. I was asked that question and, to be honest, I was a little thrown both times. I didn’t actually know why I use HAML.  I guess I’d [...]

Mongosphinx with MongoDB and MongoMapper

Can that title have the word ‘mongo’ in it any more times? Well, fear not, I’m about to use it even more…

So, I had to fool around a bit to get the so-called “Mongosphinx” gem working with my app architecture. Thought it might be helpful to others to demonstrate how I did it. [...]

Rails Metal + Thin = no 'each' for String?

Just solved an interesting problem when using the latest Thin web server (1.2.5) with Ruby 1.9.1 and Rails Metal.

The code in Rails Metal endpoint:

  def call(env)
    if env["PATH_INFO"] =~ /^\/tags.txt/
      request = Rack::Request.new(env)
      params = request.params
      query = params[’q']
      [200, { "Content-Type" => "text/plain" }, words_from(query).join("\n")]
  [...]

Sweet OS X aliases

Put all this crap in your ~/.aliases file. Do it!

alias migrate="rake db:migrate db:test:prepare"
alias remigrate="rake db:migrate && rake db:migrate:redo && rake db:schema:dump db:test:prepare"
alias gadd="git add -u && git add . && git status"
alias svnprecommit="git svn rebase && rake features && rake test"
alias cuc="cucumber -r features"
alias g="git"
alias tu="ruby_test unit"
alias tf="ruby_test functional"
alias su="ruby_tu_rs unit"
alias sf="ruby_tu_rs functional"
alias ti="ruby_test [...]